diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 755440a47fd..dda893c5350 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -53,7 +53,6 @@ $id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha');
$search_label=GETPOST('search_label','alpha');
$search_type_template=GETPOST('search_type_template','alpha');
-$search_topic=GETPOST('search_topic','alpha');
$search_lang=GETPOST('search_lang','alpha');
$search_fk_user=GETPOST('search_fk_user','intcomma');
$search_topic=GETPOST('search_topic','alpha');
@@ -94,26 +93,20 @@ $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,content";
+$tabfield[25]= "label,type_template,lang,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,content";
+$tabfieldvalue[25]= "label,type_template,fk_user,lang,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,content";
+$tabfieldinsert[25]= "label,type_template,fk_user,lang,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
-// Nom du rowid si le champ n'est pas de type autoincrement
-// Example: "" if id field is "rowid" and has autoincrement on
-// "nameoffield" if id field is not "rowid" or has not autoincrement on
-$tabrowid=array();
-$tabrowid[25]= "";
-
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[25]= true;
@@ -153,7 +146,7 @@ else
$tabhelp=array();
-$tabhelp[25] = array('topic'=>$helpsubstit,'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
+$tabhelp[25] = array('topic'=>$helpsubstit,'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
@@ -229,10 +222,12 @@ if (empty($reshook))
$ok=1;
foreach ($listfield as $f => $value)
{
+ // Not mandatory fields
+ if ($value == 'joinfiles') continue;
if ($value == 'content') continue;
if ($value == 'content_lines') continue;
- if ($value == 'content') $value='content-'.$rowid;
- if ($value == 'content_lines') $value='content_lines-'.$rowid;
+
+ if ($value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{
@@ -256,34 +251,14 @@ if (empty($reshook))
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd'))
{
- if ($tabrowid[$id])
- {
- // Recupere id libre pour insertion
- $newid=0;
- $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
- $result = $db->query($sql);
- if ($result)
- {
- $obj = $db->fetch_object($result);
- $newid=($obj->newid + 1);
-
- } else {
- dol_print_error($db);
- }
- }
-
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
- if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
- $sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
// List of values
- if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
- $sql.= $newid.",";
$i=0;
foreach ($listfieldinsert as $f => $value)
{
@@ -322,17 +297,11 @@ if (empty($reshook))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify'))
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ $rowidcol="rowid";
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
- if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
- {
- $sql.= $tabrowid[$id]."=";
- $sql.= "'".$db->escape($rowid)."', ";
- }
$i = 0;
foreach ($listfieldmodify as $field)
{
@@ -340,8 +309,10 @@ if (empty($reshook))
if ($field == 'lang') $keycode='langcode';
if ($field == 'fk_user' && ! ($_POST['fk_user'] > 0)) $_POST['fk_user']='';
+ if ($field == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
+ if ($field == 'joinfiles') $_POST['joinfiles']=$_POST['joinfiles-'.$rowid];
if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
- if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
+ if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
if ($field == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql.=",";
$sql.= $field."=";
@@ -354,7 +325,11 @@ if (empty($reshook))
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
- if (! $resql)
+ if ($resql)
+ {
+ setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
+ }
+ else
{
setEventMessages($db->error(), null, 'errors');
}
@@ -363,8 +338,7 @@ if (empty($reshook))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ $rowidcol="rowid";
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
@@ -386,15 +360,9 @@ if (empty($reshook))
// activate
if ($action == $acts[0])
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ $rowidcol="rowid";
- if ($rowid) {
- $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
- }
- elseif ($code) {
- $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
- }
+ $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
$result = $db->query($sql);
if (!$result)
@@ -406,15 +374,9 @@ if (empty($reshook))
// disable
if ($action == $acts[1])
{
- if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
- else { $rowidcol="rowid"; }
+ $rowidcol="rowid";
- if ($rowid) {
- $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
- }
- elseif ($code) {
- $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
- }
+ $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
$result = $db->query($sql);
if (!$result)
@@ -475,7 +437,7 @@ if ($action == 'delete')
//var_dump($elementList);
-$sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, content_lines, content, active";
+$sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, active";
$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates";
$sql.=" WHERE entity IN (".getEntity('email_template').")";
if (! $user->admin)
@@ -541,11 +503,14 @@ foreach ($fieldlist as $field => $value)
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
- if ($fieldlist[$field]=='content') { $valuetoshow=''; }
- if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
if ($fieldlist[$field]=='private') { $align='center'; }
if ($fieldlist[$field]=='position') { $align='center'; }
+ if ($fieldlist[$field]=='topic') { $valuetoshow=''; }
+ if ($fieldlist[$field]=='joinfiles') { $valuetoshow=''; }
+ if ($fieldlist[$field]=='content') { $valuetoshow=''; }
+ if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
+
if ($valuetoshow != '')
{
print '
';
@@ -560,14 +525,11 @@ foreach ($fieldlist as $field => $value)
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
-print '
';
+print '
';
print '';
print '
';
print '';
-// Line to enter new values (input fields)
-print "
";
-
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd'))
@@ -587,6 +549,10 @@ $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters,
$error = $hookmanager->error;
$errors = $hookmanager->errors;
+
+// Line to enter new values (input fields)
+print "
";
+
if (empty($reshook))
{
if ($action == 'edit') {
@@ -596,32 +562,51 @@ if (empty($reshook))
}
}
-print '
';
- $fieldsforcontent = array('content');
+ $fieldsforcontent = array('topic', 'joinfiles', 'content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
- $fieldsforcontent = array('content', 'content_lines');
+ $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
}
foreach ($fieldsforcontent as $tmpfieldlist)
{
@@ -799,17 +785,29 @@ if ($resql)
$class = 'tddict';
// Show value for field
if ($showfield) {
-
+ // Show line for topic, joinfiles and content
print '
';
- print '
'; // To create an artificial CR for the current tr we are on
- $okforextended = true;
- if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
- $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
- print $doleditor->Create(1);
+ print '
';
}
}
}
@@ -856,6 +854,10 @@ if ($resql)
{
$align="center";
}
+ if ($value == 'joinfiles')
+ {
+ $align="center";
+ }
$class='tddict';
// Show value for field
@@ -880,24 +882,21 @@ if ($resql)
if ($param) $url .= '&'.$param;
$url.='&';
- // Active
+ // Status / Active
print '