diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 55671345385..d4862e2a7b3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -160,7 +160,8 @@ if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$lang if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); -$elementList['other']=$langs->trans('Other'); +$elementList['all']=$langs->trans('VisibleEverywhere'); +$elementList['none']=$langs->trans('VisibleNowhere'); $parameters=array('elementList'=>$elementList); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 4ec9c91aa80..26ad86fc845 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -313,7 +313,7 @@ class FormMail extends Form } $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); - if ($result<0) + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } @@ -321,6 +321,9 @@ class FormMail extends Form foreach($this->lines_model as $line) { $modelmail_array[$line->id]=$line->label; + if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')'; + if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private"); + //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' '; } // Zone to select its email template @@ -337,11 +340,11 @@ class FormMail extends Form elseif (! empty($this->param['models']) && in_array($this->param['models'], array( 'propal_send','order_send','facture_send', 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', - 'invoice_supplier_send','thirdparty' + 'invoice_supplier_send','thirdparty','all' ))) { $out.= '
'."\n"; - $out.= $langs->trans('SelectMailModel').': '; // Do not put disabled on option, it is already on select and it makes chrome crazy. + $out.= $langs->trans('SelectMailModel').': '; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy. if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; @@ -373,7 +376,7 @@ class FormMail extends Form { $out.= ''; $out.= ''; - $out.= ''.$langs->trans("MailFrom").''; + $out.= ''.$langs->trans("MailFrom").''; if (! ($this->fromtype === 'user' && $this->fromid > 0) && ! ($this->fromtype === 'company') @@ -939,7 +942,7 @@ class FormMail extends Form } /** - * Find if template exists + * Find if template exists and are available for current user, then set them into $this->lines_module. * Search into table c_email_templates * * @param string $type_template Get message for key module @@ -952,13 +955,13 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT rowid, label, topic, content, content_lines, lang, position"; + $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; + $sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; - $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; + $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. if ($active >= 0) $sql.=" AND active = ".$active; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; + //if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages $sql.= $this->db->order("position,lang,label","ASC"); //print $sql; @@ -972,10 +975,13 @@ class FormMail extends Form $line = new ModelMail(); $line->id=$obj->rowid; $line->label=$obj->label; + $line->lang=$obj->lang; + $line->fk_user=$obj->fk_user; + $line->private=$obj->private; + $line->position=$obj->position; $line->topic=$obj->topic; $line->content=$obj->content; $line->content_lines=$obj->content_lines; - $line->lang=$obj->lang; $this->lines_model[]=$line; } $this->db->free($resql); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7d79fa0c62c..ce52b74beb6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1674,6 +1674,8 @@ OpportunityPercent=When you create an opportunity, you will defined an estimated TemplateForElement=This template record is dedicated to which element TypeOfTemplate=Type of template TemplateIsVisibleByOwnerOnly=Template is visible by owner only +VisibleEverywhere=Visible everywhere +VisibleNowhere=Visible nowhere FixTZ=TimeZone fix FillFixTZOnlyIfRequired=Example: +2 (fill only if problem experienced) ExpectedChecksum=Expected Checksum diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b802840a72e..e9d3b0ec141 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -24,7 +24,7 @@ FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p FormatDateHourTextShort=%b %d, %Y, %I:%M %p FormatDateHourText=%B %d, %Y, %I:%M %p DatabaseConnection=Database connection -NoTemplateDefined=No template defined for this email type +NoTemplateDefined=No template available for this email type AvailableVariables=Available substitution variables NoTranslation=No translation NoRecordFound=No record found @@ -835,7 +835,7 @@ ShortThursday=T ShortFriday=F ShortSaturday=S ShortSunday=S -SelectMailModel=Select email template +SelectMailModel=Select an email template SetRef=Set ref Select2ResultFoundUseArrows=Some results found. Use arrows to select. Select2NotFound=No result found