diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php
index 292b9c77339..88514d83da3 100644
--- a/htdocs/adherents/admin/adherent_emails.php
+++ b/htdocs/adherents/admin/adherent_emails.php
@@ -39,7 +39,7 @@ $langs->load("members");
if (! $user->admin) accessforbidden();
-$type=array('yesno','texte','chaine');
+$oldtypetonewone=array('texte'=>'text','chaine'=>'string'); // old type to new ones
$action = GETPOST('action','alpha');
@@ -53,20 +53,7 @@ if ($action == 'updateall')
{
$db->begin();
$res1=$res2=$res3=$res4=$res5=$res6=0;
- $res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
- $res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
- $res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
- $res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
- // Use vat for invoice creation
- if ($conf->facture->enabled)
- {
- $res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
- $res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
- if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
- {
- $res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
- }
- }
+ $res1=dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
{
setEventMessages('ErrorFailedToSaveDate', null, 'errors');
@@ -82,19 +69,16 @@ if ($action == 'updateall')
// Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add')
{
+ $constlineid = GETPOST('rowid','int');
$constname=GETPOST('constname','alpha');
- $constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
- if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue='';
- if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
- {
- if ($constvalue) $constvalue=0;
- else $constvalue=1;
- }
+ $constvalue=(GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
+ $consttype=(GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
+ $constnote=(GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
- $consttype=GETPOST('consttype','alpha');
- $constnote=GETPOST('constnote');
- $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
+ $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
+
+ $res=dolibarr_set_const($db,$constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
if (! $res > 0) $error++;
@@ -111,7 +95,7 @@ if ($action == 'update' || $action == 'add')
// Action activation d'un sous module du module adherent
if ($action == 'set')
{
- $result=dolibarr_set_const($db, GETPOST('name','alpha'),GETPOST('value'),'',0,'',$conf->entity);
+ $result=dolibarr_set_const($db, GETPOST('name','alpha'), GETPOST('value'), '', 0, '', $conf->entity);
if ($result < 0)
{
print $db->error();
@@ -157,23 +141,15 @@ print '';
* Editing global variables not related to a specific theme
*/
$constantes=array(
- 'ADHERENT_MAIL_FROM',
- 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT',
- 'ADHERENT_AUTOREGISTER_NOTIF_MAIL',
- 'ADHERENT_AUTOREGISTER_MAIL_SUBJECT',
- 'ADHERENT_AUTOREGISTER_MAIL',
- 'ADHERENT_MAIL_VALID_SUBJECT',
- 'ADHERENT_MAIL_VALID',
- 'ADHERENT_MAIL_COTIS_SUBJECT',
- 'ADHERENT_MAIL_COTIS',
- 'ADHERENT_MAIL_RESIL_SUBJECT',
- 'ADHERENT_MAIL_RESIL',
- );
-
-$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
';
-$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
-$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
-$helptext.='__YEAR__, __MONTH__, __DAY__';
+ 'ADHERENT_MAIL_FROM'=>'string',
+ 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
+ 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
+ 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
+ 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
+ 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
+ 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
+ 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
+);
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 81757aab9e0..41a49bd386d 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -1353,7 +1353,7 @@ else
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
$texttosend=$object->makeSubstitution($adht->getMailOnValid());
- $tmp=$langs->trans("SendAnEMailToMember");
+ $tmp=$langs->trans("SendingAnEMailToMember");
$tmp.='
'.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', ';
$tmp.='
'.$langs->trans("MailRecipient").': '.$object->email.'';
$helpcontent='';
@@ -1395,7 +1395,7 @@ else
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
$texttosend=$object->makeSubstitution($adht->getMailOnResiliate());
- $tmp=$langs->trans("SendAnEMailToMember");
+ $tmp=$langs->trans("SendingAnEMailToMember");
$tmp.='
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', ';
$tmp.=$langs->trans("MailRecipient").': '.$object->email.')';
$helpcontent='';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index a22a2d57c0d..3ef7af75ceb 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -2562,9 +2562,12 @@ class Adherent extends CommonObject
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
- $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, '(SendReminderForExpiredSubscriptionTitle)');
+ $arraydefaultmessage=null;
+ $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
- if (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
+ if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
+
+ if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent);
//if (is_array($adherent->thirdparty)) $substitutionarraycomp = ...
@@ -2591,7 +2594,7 @@ class Adherent extends CommonObject
}
else
{
- $blockingerrormsg="Can't find email template '(SendReminderForExpiredSubscriptionTitle)'";
+ $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding";
$nbko++;
break;
}
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 21d3cb2eae5..79c4d4765be 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -91,17 +91,17 @@ $tabsqlsort[25]="label ASC, lang ASC, position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
-$tabfield[25]= "label,type_template,lang,fk_user,private,position,topic,joinfiles,content";
+$tabfield[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines';
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
-$tabfieldvalue[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
+$tabfieldvalue[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines';
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
-$tabfieldinsert[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
+$tabfieldinsert[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines';
$tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays
@@ -233,8 +233,7 @@ if (empty($reshook))
$ok=0;
$fieldnamekey=$listfield[$f];
// We take translate key of field
- if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
- if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
+ if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Code';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate';
@@ -478,7 +477,7 @@ foreach ($fieldlist as $field => $value)
if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? ' ' : $langs->trans("Language")); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
- if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
+ if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field]=='private') { $align='center'; }
if ($fieldlist[$field]=='position') { $align='center'; }
@@ -695,7 +694,7 @@ if ($resql)
if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
- if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
+ if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field]=='private') { $align='center'; }
if ($fieldlist[$field]=='position') { $align='center'; }
@@ -990,7 +989,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{
$selectedlang = $langs->defaultlang;
if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
- print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1);
+ print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150');
}
else
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 32172ea60f0..8c575b6478e 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5421,23 +5421,23 @@ class Form
* Return a HTML select string, built from an array of key+value.
* Note: Do not apply langs->trans function on returned content, content may be entity encoded twice.
*
- * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
- * @param array $array Array (key => value)
- * @param string|string[] $id Preselected key or preselected keys for multiselect
- * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (key is -1 and value is '' or ' ' if 1, key is -1 and value is text if string), <0 to add an empty value with key that is this value.
- * @param int $key_in_label 1 to show key into label with format "[key] value"
- * @param int $value_as_key 1 to use value as key
- * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
- * @param int $translate 1=Translate and encode value
- * @param int $maxlen Length maximum for labels
- * @param int $disabled Html select box is disabled
- * @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
- * @param string $morecss Add more class to css styles
- * @param int $addjscombo Add js combo
- * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set
- * @param int $disablebademail Check if an email is found into value and if not disable and colorize entry
- * @param int $nohtmlescape No html escaping.
- * @return string HTML select string.
+ * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
+ * @param array $array Array (key => value)
+ * @param string|string[] $id Preselected key or preselected keys for multiselect
+ * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (key is -1 and value is '' or ' ' if 1, key is -1 and value is text if string), <0 to add an empty value with key that is this value.
+ * @param int $key_in_label 1 to show key into label with format "[key] value"
+ * @param int $value_as_key 1 to use value as key
+ * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
+ * @param int $translate 1=Translate and encode value
+ * @param int $maxlen Length maximum for labels
+ * @param int $disabled Html select box is disabled
+ * @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
+ * @param string $morecss Add more class to css styles
+ * @param int $addjscombo Add js combo
+ * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set
+ * @param int $disablebademail Check if an email is found into value and if not disable and colorize entry
+ * @param int $nohtmlescape No html escaping.
+ * @return string HTML select string.
* @see multiselectarray
*/
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='',$disablebademail=0, $nohtmlescape=0)
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 33aab58eb2e..2a93a3dc2b6 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -998,7 +998,7 @@ class FormMail extends Form
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
* @param int $active 1=Only active template, 0=Only disabled, -1=All
* @param string $label Label of template
- * @return ModelMail
+ * @return ModelMail One instance of ModelMail
*/
public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='')
{
@@ -1153,6 +1153,7 @@ class FormMail extends Form
$line->topic=$obj->topic;
$line->content=$obj->content;
$line->content_lines=$obj->content_lines;
+
$this->lines_model[]=$line;
}
$this->db->free($resql);
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 4bd9b097b3d..85a9be1f0fd 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1321,14 +1321,15 @@ function complete_elementList_with_modules(&$elementList)
/**
* Show array with constants to edit
*
- * @param array $tableau Array of constants
+ * @param array $tableau Array of constants array('key'=>type, ) where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ...
* @param int $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (no form into table), 2=No form nor button at all
* @param string $helptext Help
* @return void
*/
function form_constantes($tableau, $strictw3c=0, $helptext='')
{
- global $db,$bc,$langs,$conf,$_Avery_Labels;
+ global $db,$bc,$langs,$conf,$user;
+ global $_Avery_Labels;
$form = new Form($db);
@@ -1343,11 +1344,20 @@ function form_constantes($tableau, $strictw3c=0, $helptext='')
print '';
if (empty($strictw3c)) print '