dolibarr  9.0.0
mails_templates.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
8  * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
9  * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
10  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
11  * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
12  * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
13  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <http://www.gnu.org/licenses/>.
28  */
29 
36 require '../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array("errors","admin","mails","languages"));
47 
48 $action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
49 $confirm = GETPOST('confirm','alpha'); // Result of a confirmation
50 
51 $id = GETPOST('id','int');
52 $rowid = GETPOST('rowid','alpha');
53 $search_label=GETPOST('search_label','alpha');
54 $search_type_template=GETPOST('search_type_template','alpha');
55 $search_lang=GETPOST('search_lang','alpha');
56 $search_fk_user=GETPOST('search_fk_user','intcomma');
57 $search_topic=GETPOST('search_topic','alpha');
58 
59 if (! empty($user->socid)) accessforbidden();
60 
61 $acts[0] = "activate";
62 $acts[1] = "disable";
63 $actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
64 $actl[1] = img_picto($langs->trans("Activated"),'switch_on');
65 
66 $listoffset=GETPOST('listoffset','alpha');
67 $listlimit =GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000;
68 $active = 1;
69 
70 $sortfield = GETPOST("sortfield",'alpha');
71 $sortorder = GETPOST("sortorder",'alpha');
72 $page = GETPOST("page",'int');
73 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
74 $offset = $listlimit * $page ;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
77 
78 if (empty($sortfield)) $sortfield='type_template, lang, position, label';
79 if (empty($sortorder)) $sortorder='ASC';
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $hookmanager->initHooks(array('emailtemplates'));
83 
84 // Name of SQL tables of dictionaries
85 $tabname=array();
86 $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
87 
88 // Nom des champs en resultat de select pour affichage du dictionnaire
89 $tabfield=array();
90 $tabfield[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
91 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines';
92 
93 // Nom des champs d'edition pour modification d'un enregistrement
94 $tabfieldvalue=array();
95 $tabfieldvalue[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
96 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines';
97 
98 // Nom des champs dans la table pour insertion d'un enregistrement
99 $tabfieldinsert=array();
100 $tabfieldinsert[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
101 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines';
102 $tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays
103 
104 // Condition to show dictionary in setup page
105 $tabcond=array();
106 $tabcond[25]= true;
107 
108 // List of help for fields
109 // Set MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES to allow edit of template for lines
110 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
111 $formmail=new FormMail($db);
112 if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
113 {
114  $tmp=FormMail::getAvailableSubstitKey('formemail');
115  $tmp['__(AnyTranslationKey)__']='Translation';
116  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
117  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
118  foreach($tmp as $key => $val)
119  {
120  $helpsubstit.=$key.' -> '.$val.'<br>';
121  $helpsubstitforlines.=$key.' -> '.$val.'<br>';
122  }
123 }
124 else
125 {
126  $tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
127  $tmp['__(AnyTranslationKey)__']='Translation';
128  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
129  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
130  foreach($tmp as $key => $val)
131  {
132  $helpsubstit.=$key.' -> '.$val.'<br>';
133  }
134  $tmp=FormMail::getAvailableSubstitKey('formemailforlines');
135  foreach($tmp as $key => $val)
136  {
137  $helpsubstitforlines.=$key.' -> '.$val.'<br>';
138  }
139 }
140 
141 
142 $tabhelp=array();
143 $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"));
144 
145 // List of check for fields (NOT USED YET)
146 $tabfieldcheck=array();
147 $tabfieldcheck[25] = array();
148 
149 
150 // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
151 $elementList = array();
152 $sourceList=array();
153 
154 // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
155 $elementList = array();
156 if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal');
157 if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder');
158 if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice');
159 if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment');
160 if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention');
161 if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation');
162 if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');
163 if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice');
164 if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
165 if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
166 if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
167 if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject');
168 $elementList['user']=$langs->trans('MailToUser');
169 
170 $parameters=array('elementList'=>$elementList);
171 $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks
172 if ($reshook == 0) {
173  foreach ($hookmanager->resArray as $item => $value) {
174  $elementList[$item] = $value;
175  }
176 }
177 
178 // Add all and none after the sort
179 $elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')';
180 $elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')';
181 
182 asort($elementList);
183 
184 $id = 25;
185 
186 
187 /*
188  * Actions
189  */
190 
191 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
192 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
193 
194 $parameters=array();
195 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
196 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
197 
198 if (empty($reshook))
199 {
200  // Purge search criteria
201  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
202  {
203  $search_label='';
204  $search_type_template='';
205  $search_lang='';
206  $search_fk_user='';
207  $search_topic='';
208  $toselect='';
209  $search_array_options=array();
210  }
211 
212  // Actions add or modify an entry into a dictionary
213  if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
214  {
215  $listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
216  $listfieldinsert=explode(',',$tabfieldinsert[$id]);
217  $listfieldmodify=explode(',',$tabfieldinsert[$id]);
218  $listfieldvalue=explode(',',$tabfieldvalue[$id]);
219 
220  // Check that all fields are filled
221  $ok=1;
222  foreach ($listfield as $f => $value)
223  {
224  // Not mandatory fields
225  if ($value == 'joinfiles') continue;
226  if ($value == 'content') continue;
227  if ($value == 'content_lines') continue;
228 
229  if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
230 
231  if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
232  {
233  $ok=0;
234  $fieldnamekey=$listfield[$f];
235  // We take translate key of field
236  if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Code';
237  if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
238  if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
239  if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate';
240  if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner';
241  if ($fieldnamekey == 'private') $fieldnamekey = 'Private';
242  if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
243  if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic';
244 
245  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
246  }
247  }
248 
249  // Si verif ok et action add, on ajoute la ligne
250  if ($ok && GETPOST('actionadd'))
251  {
252  // Add new entry
253  $sql = "INSERT INTO ".$tabname[$id]." (";
254  // List of fields
255  $sql.= $tabfieldinsert[$id];
256  $sql.=",active)";
257  $sql.= " VALUES(";
258 
259  // List of values
260  $i=0;
261  foreach ($listfieldinsert as $f => $value)
262  {
263  //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
264  $keycode=$listfieldvalue[$i];
265  if ($value == 'lang') $keycode='langcode';
266  if ($value == 'entity') $_POST[$keycode] = $conf->entity;
267  if ($i) $sql.=",";
268  if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
269  if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0';
270  if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1';
271  if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
272  elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work
273  else $sql.="'".$db->escape($_POST[$keycode])."'";
274  $i++;
275  }
276  $sql.=",1)";
277 
278  dol_syslog("actionadd", LOG_DEBUG);
279  $result = $db->query($sql);
280  if ($result) // Add is ok
281  {
282  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
283  $_POST=array('id'=>$id); // Clean $_POST array, we keep only
284  }
285  else
286  {
287  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
288  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
289  }
290  else {
291  dol_print_error($db);
292  }
293  }
294  }
295 
296  // Si verif ok et action modify, on modifie la ligne
297  if ($ok && GETPOST('actionmodify'))
298  {
299  $rowidcol="rowid";
300 
301  // Modify entry
302  $sql = "UPDATE ".$tabname[$id]." SET ";
303  // Modifie valeur des champs
304  $i = 0;
305  foreach ($listfieldmodify as $field)
306  {
307  $keycode=$listfieldvalue[$i];
308  if ($field == 'lang') $keycode='langcode';
309 
310  if ($field == 'fk_user' && ! ($_POST['fk_user'] > 0)) $_POST['fk_user']='';
311  if ($field == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
312  if ($field == 'joinfiles') $_POST['joinfiles']=$_POST['joinfiles-'.$rowid];
313  if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
314  if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
315  if ($field == 'entity') $_POST[$keycode] = $conf->entity;
316  if ($i) $sql.=",";
317  $sql.= $field."=";
318 
319  //print $keycode.' - '.$_POST[$keycode].'<br>';
320  if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
321  elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work
322  elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1
323  elseif ($keycode == 'position') $sql.=((int) $_POST[$keycode]);
324  else $sql.="'".$db->escape($_POST[$keycode])."'";
325  $i++;
326  }
327  $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
328 //print $sql;exit;
329  dol_syslog("actionmodify", LOG_DEBUG);
330  //print $sql;
331  $resql = $db->query($sql);
332  if ($resql)
333  {
334  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
335  }
336  else
337  {
338  setEventMessages($db->error(), null, 'errors');
339  }
340  }
341  }
342 
343  if ($action == 'confirm_delete' && $confirm == 'yes') // delete
344  {
345  $rowidcol="rowid";
346 
347  $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
348 
349  dol_syslog("delete", LOG_DEBUG);
350  $result = $db->query($sql);
351  if (! $result)
352  {
353  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
354  {
355  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
356  }
357  else
358  {
359  dol_print_error($db);
360  }
361  }
362  }
363 
364  // activate
365  if ($action == $acts[0])
366  {
367  $rowidcol="rowid";
368 
369  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
370 
371  $result = $db->query($sql);
372  if (!$result)
373  {
374  dol_print_error($db);
375  }
376  }
377 
378  // disable
379  if ($action == $acts[1])
380  {
381  $rowidcol="rowid";
382 
383  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
384 
385  $result = $db->query($sql);
386  if (!$result)
387  {
388  dol_print_error($db);
389  }
390  }
391 }
392 
393 
394 /*
395  * View
396  */
397 
398 $form = new Form($db);
399 $formadmin=new FormAdmin($db);
400 
401 llxHeader();
402 
403 $titre=$langs->trans("EMailsSetup");
404 $linkback='';
405 $titlepicto='title_setup';
406 
407 print load_fiche_titre($titre,$linkback,$titlepicto);
408 
409 $head = email_admin_prepare_head();
410 
411 dol_fiche_head($head, 'templates', '', -1);
412 
413 // Confirmation de la suppression de la ligne
414 if ($action == 'delete')
415 {
416  print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
417 }
418 //var_dump($elementList);
419 
420 
421 $sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active";
422 $sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates";
423 $sql.=" WHERE entity IN (".getEntity('email_template').")";
424 if (! $user->admin)
425 {
426  $sql.=" AND (private = 0 OR (private = 1 AND fk_user = ".$user->id."))"; // Show only public and private to me
427  $sql.=" AND (active = 1 OR fk_user = ".$user->id.")"; // Show only active or owned by me
428 }
429 if (empty($conf->global->MAIN_MULTILANGS))
430 {
431  $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')";
432 }
433 if ($search_label) $sql.=natural_search('label', $search_label);
434 if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template);
435 if ($search_lang) $sql.=natural_search('lang', $search_lang);
436 if ($search_fk_user != '' && $search_fk_user != '-1') $sql.=natural_search('fk_user', $search_fk_user, 2);
437 if ($search_topic) $sql.=natural_search('topic', $search_topic);
438 // If sort order is "country", we use country_code instead
439 if ($sortfield == 'country') $sortfield='country_code';
440 $sql.=$db->order($sortfield,$sortorder);
441 $sql.=$db->plimit($listlimit+1,$offset);
442 //print $sql;
443 
444 $fieldlist=explode(',',$tabfield[$id]);
445 
446 // Form to add a new line
447 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
448 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
449 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
450 
451 print '<div class="div-table-responsive-no-min">';
452 print '<table class="noborder" width="100%">';
453 
454 // Line to enter new values (title)
455 print '<tr class="liste_titre">';
456 foreach ($fieldlist as $field => $value)
457 {
458  // Determine le nom du champ par rapport aux noms possibles
459  // dans les dictionnaires de donnees
460  $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
461  $valuetoshow=$langs->trans($valuetoshow); // try to translate
462  $align="left";
463  if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");}
464  if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? '&nbsp;' : $langs->trans("Language")); }
465  if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
466  if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
467  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
468  if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
469  if ($fieldlist[$field]=='private') { $align='center'; }
470  if ($fieldlist[$field]=='position') { $align='center'; }
471 
472  if ($fieldlist[$field]=='topic') { $valuetoshow=''; }
473  if ($fieldlist[$field]=='joinfiles') { $valuetoshow=''; }
474  if ($fieldlist[$field]=='content') { $valuetoshow=''; }
475  if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
476 
477  if ($valuetoshow != '')
478  {
479  print '<td align="'.$align.'">';
480  if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
481  else if (! empty($tabhelp[$id][$value]))
482  {
483  if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
484  else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
485  }
486  else print $valuetoshow;
487  print '</td>';
488  }
489 }
490 print '<td>';
491 print '<input type="hidden" name="id" value="' . $id . '">';
492 print '</td>';
493 print '</tr>';
494 
495 $obj = new stdClass();
496 // If data was already input, we define them in obj to populate input fields.
497 if (GETPOST('actionadd'))
498 {
499  foreach ($fieldlist as $key => $val) {
500  if (GETPOST($val) != '')
501  $obj->$val = GETPOST($val);
502  }
503 }
504 
505 $tmpaction = 'create';
506 $parameters = array(
507  'fieldlist' => $fieldlist,
508  'tabname' => $tabname[$id]
509 );
510 $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
511 $error = $hookmanager->error;
512 $errors = $hookmanager->errors;
513 
514 
515 // Line to enter new values (input fields)
516 print "<tr " . $bcnd[$var] . ">";
517 
518 if (empty($reshook))
519 {
520  if ($action == 'edit') {
521  fieldList($fieldlist, $obj, $tabname[$id], 'hide');
522  } else {
523  fieldList($fieldlist, $obj, $tabname[$id], 'add');
524  }
525 }
526 
527 print '<td align="right">';
528 print '</td>';
529 print "</tr>";
530 
531 // Show fields for topic, join files and body
532 $fieldsforcontent = array('topic', 'joinfiles', 'content');
533 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('content','content_lines'); }
534 foreach ($fieldsforcontent as $tmpfieldlist)
535 {
536  print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
537  // Label
538  if ($tmpfieldlist == 'topic')
539  {
540  print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
541  }
542  if ($tmpfieldlist == 'joinfiles')
543  {
544  print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
545  }
546  if ($tmpfieldlist == 'content')
547  print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist);
548  if ($tmpfieldlist == 'content_lines')
549  print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '<br>';
550  // Input field
551  if ($tmpfieldlist == 'topic') {
552  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
553  }
554  else if ($tmpfieldlist == 'joinfiles') {
555  print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'" value="' . (isset($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '1') . '">';
556  }
557  else
558  {
559  if ($context != 'hide') {
560  // print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
561  $okforextended = true;
562  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
563  $okforextended = false;
564  $doleditor = new DolEditor($tmpfieldlist, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
565  print $doleditor->Create(1);
566  }
567  else
568  print '&nbsp;';
569  }
570  print '</td>';
571  if ($tmpfieldlist == 'topic') {
572  print '<td align="center" rowspan="' . (count($fieldsforcontent)) . '">';
573  if ($action != 'edit') {
574  print '<input type="submit" class="button" name="actionadd" value="' . $langs->trans("Add") . '">';
575  }
576  print '</td>';
577  }
578  // else print '<td></td>';
579  print '</tr>';
580 }
581 
582 
583 
584 $colspan=count($fieldlist)+1;
585 //print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
586 
587 print '</table>';
588 print '</div>';
589 print '</form>';
590 print '<br>';
591 
592 
593 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
594 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
595 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
596 
597 print '<div class="div-table-responsive-no-min">';
598 print '<table class="noborder" width="100%">';
599 
600 // List of available record in database
601 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
602 $resql=$db->query($sql);
603 if ($resql)
604 {
605  $num = $db->num_rows($resql);
606  $i = 0;
607 
608  $param = '&id='.$id;
609  if ($search_label) $param.= '&search_label='.urlencode($search_label);
610  if ($search_lang > 0) $param.= '&search_lang='.urlencode($search_lang);
611  if ($search_type_template > 0) $param.= '&search_type_template='.urlencode($search_type_template);
612  if ($search_fk_user > 0) $param.= '&search_fk_user='.urlencode($search_fk_user);
613  if ($search_topic) $param.= '&search_topic='.urlencode($search_topic);
614 
615  $paramwithsearch = $param;
616  if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder);
617  if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield);
618  if (GETPOST('from','alpha')) $paramwithsearch.= '&from='.urlencode(GETPOST('from','alpha'));
619 
620  // There is several pages
621  if ($num > $listlimit)
622  {
623  print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
624  print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
625  print '</td></tr>';
626  }
627 
628 
629  // Title line with search boxes
630  print '<tr class="liste_titre">';
631  $filterfound=0;
632  foreach ($fieldlist as $field => $value)
633  {
634  if ($value == 'label') print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>';
635  elseif ($value == 'lang')
636  {
637  print '<td class="liste_titre">';
638  print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
639  print '</td>';
640  }
641  elseif ($value == 'fk_user')
642  {
643  print '<td class="liste_titre">';
644  $restrictid=array();
645  if (! $user->admin) $restrictid=array($user->id);
646  //var_dump($restrictid);
647  print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100');
648  print '</td>';
649  }
650  elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
651  elseif ($value == 'type_template')
652  {
653  print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').'</td>';
654  }
655  elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
656  }
657  if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
658  // Action column
659  print '<td class="liste_titre" align="right" width="64">';
660  $searchpicto=$form->showFilterButtons();
661  print $searchpicto;
662  print '</td>';
663  print '</tr>';
664 
665  // Title of lines
666  print '<tr class="liste_titre">';
667  foreach ($fieldlist as $field => $value)
668  {
669  // Determine le nom du champ par rapport aux noms possibles
670  // dans les dictionnaires de donnees
671  $showfield=1; // By defaut
672  $align="left";
673  $sortable=1;
674  $valuetoshow='';
675  $forcenowrap=1;
676  /*
677  $tmparray=getLabelOfField($fieldlist[$field]);
678  $showfield=$tmp['showfield'];
679  $valuetoshow=$tmp['valuetoshow'];
680  $align=$tmp['align'];
681  $sortable=$tmp['sortable'];
682  */
683  $valuetoshow=ucfirst($fieldlist[$field]); // By defaut
684  $valuetoshow=$langs->trans($valuetoshow); // try to translate
685  if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner"); }
686  if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
687  if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
688  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
689  if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
690  if ($fieldlist[$field]=='private') { $align='center'; }
691  if ($fieldlist[$field]=='position') { $align='center'; }
692 
693  if ($fieldlist[$field]=='joinfiles') { $valuetoshow=$langs->trans("FilesAttachedToEmail"); $align='center'; $forcenowrap=0; }
694  if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;}
695  if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; }
696 
697  // Affiche nom du champ
698  if ($showfield)
699  {
700  if (! empty($tabhelp[$id][$value]))
701  {
702  if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
703  else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
704  }
705  print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
706  }
707  }
708 
709  print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
711  print '</tr>';
712 
713  if ($num)
714  {
715  // Lines with values
716  while ($i < $num)
717  {
718  $obj = $db->fetch_object($resql);
719 
720  if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
721  {
722  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
723 
724  $tmpaction='edit';
725  $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
726  $reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
727  $error=$hookmanager->error; $errors=$hookmanager->errors;
728 
729  // Show fields
730  if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
731 
732  print '<td></td><td></td><td></td>';
733  print '<td align="center">';
734  print '<input type="hidden" name="page" value="'.$page.'">';
735  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
736  print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
737  print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
738  print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
739  print '</td>';
740 
741  $fieldsforcontent = array('topic', 'joinfiles', 'content');
742  if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
743  {
744  $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
745  }
746  foreach ($fieldsforcontent as $tmpfieldlist)
747  {
748  $showfield = 1;
749  $align = "left";
750  $valuetoshow = $obj->{$tmpfieldlist};
751 
752  $class = 'tddict';
753  // Show value for field
754  if ($showfield) {
755  // Show line for topic, joinfiles and content
756  print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' ">';
757  print '<td colspan="8">';
758  if ($tmpfieldlist == 'topic')
759  {
760  print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
761  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
762  }
763  if ($tmpfieldlist == 'joinfiles')
764  {
765  print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
766  print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
767  }
768  if ($tmpfieldlist == 'content')
769  {
770  print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '<br>';
771  $okforextended = true;
772  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
773  $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
774  print $doleditor->Create(1);
775  }
776  print '</td>';
777  print '<td></td>';
778  print '<td></td>';
779  }
780  }
781 
782  print "</tr>\n";
783  }
784  else
785  {
786  $keyforobj='type_template';
787  if (! in_array($obj->$keyforobj, array_keys($elementList)))
788  {
789  $i++;
790  continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
791  }
792  // Test on 'enabled'
793  if (! dol_eval($obj->enabled, 1))
794  {
795  $i++;
796  continue; // Email template not qualified
797  }
798 
799  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
800 
801  $tmpaction = 'view';
802  $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
803  $reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
804 
805  $error=$hookmanager->error; $errors=$hookmanager->errors;
806 
807  if (empty($reshook))
808  {
809  foreach ($fieldlist as $field => $value)
810  {
811  if (in_array($fieldlist[$field], array('content','content_lines'))) continue;
812  $showfield=1;
813  $align="left";
814  $valuetoshow=$obj->{$fieldlist[$field]};
815  if ($value == 'type_template')
816  {
817  $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
818  }
819  if ($value == 'lang' && $valuetoshow)
820  {
821  $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
822  }
823  if ($value == 'fk_user')
824  {
825  if ($valuetoshow > 0)
826  {
827  $fuser=new User($db);
828  $fuser->fetch($valuetoshow);
829  $valuetoshow = $fuser->getNomUrl(1);
830  }
831  }
832  if ($value == 'private')
833  {
834  $align="center";
835  if ($valuetoshow) $valuetoshow=yn($valuetoshow);
836  else $valuetoshow='';
837  }
838  if ($value == 'position')
839  {
840  $align="center";
841  }
842  if ($value == 'joinfiles')
843  {
844  $align="center";
845  if ($valuetoshow) $valuetoshow=1;
846  else $valuetoshow='';
847  }
848 
849  $class='tddict';
850  // Show value for field
851  if ($showfield)
852  {
853  print '<!-- '.$fieldlist[$field].' -->';
854  print '<td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
855  }
856  }
857  }
858 
859  // Can an entry be erased or disabled ?
860  $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
861  if (! $user->admin && $obj->fk_user != $user->id)
862  {
863  $iserasable=0;
864  $canbedisabled=0;
865  $canbemodified=0;
866  }
867 
868  $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
869  if ($param) $url .= '&'.$param;
870  $url.='&';
871 
872  // Status / Active
873  print '<td align="center" class="nowrap">';
874  if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
875  print "</td>";
876 
877  // Modify link / Delete link
878  print '<td class="center nowraponall" width="64">';
879  if ($canbemodified) print '<a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a>';
880  if ($iserasable)
881  {
882  print ' &nbsp; <a href="'.$url.'action=delete">'.img_delete().'</a>';
883  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
884  }
885  print '</td>';
886 
887  /*
888  $fieldsforcontent = array('content');
889  if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
890  {
891  $fieldsforcontent = array('content', 'content_lines');
892  }
893  foreach ($fieldsforcontent as $tmpfieldlist)
894  {
895  $showfield = 1;
896  $align = "left";
897  $valuetoshow = $obj->{$tmpfieldlist};
898 
899  $class = 'tddict';
900  // Show value for field
901  if ($showfield) {
902 
903  print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$i.' "><td colspan="5">'; // To create an artificial CR for the current tr we are on
904  $okforextended = true;
905  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
906  $okforextended = false;
907  $doleditor = new DolEditor($tmpfieldlist.'-'.$i, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%', 1);
908  print $doleditor->Create(1);
909  print '</td>';
910  print '<td></td><td></td><td></td>';
911 
912  }
913  }*/
914 
915  print "</tr>\n";
916  }
917 
918 
919  $i++;
920  }
921  }
922 }
923 else {
924  dol_print_error($db);
925 }
926 
927 print '</table>';
928 print '</div>';
929 
930 print '</form>';
931 
932 
933 dol_fiche_end();
934 
935 // End of page
936 llxFooter();
937 $db->close();
938 
939 
949 function fieldList($fieldlist, $obj='', $tabname='', $context='')
950 {
951  global $conf, $langs, $user, $db;
952  global $form;
953  global $region_id;
954  global $elementList,$sourceList,$localtax_typeList;
955  global $bc;
956 
957  $formadmin = new FormAdmin($db);
958  $formcompany = new FormCompany($db);
959 
960  foreach ($fieldlist as $field => $value)
961  {
962  if ($fieldlist[$field] == 'fk_user')
963  {
964  print '<td>';
965  if ($user->admin)
966  {
967  print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, '', null, 0, 0, 1, '', 0, '', 'maxwidth200');
968  }
969  else
970  {
971  if ($context == 'add') // I am not admin and we show the add form
972  {
973  print $user->getNomUrl(1); // Me
974  $forcedvalue=$user->id;
975  }
976  else
977  {
978  if ($obj && ! empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0)
979  {
980  $fuser=new User($db);
981  $fuser->fetch($obj->{$fieldlist[$field]});
982  print $fuser->getNomUrl(1);
983  $forcedvalue=$fuser->id;
984  }
985  else
986  {
987  $forcedvalue=$obj->{$fieldlist[$field]};
988  }
989  }
990  $keyname=$fieldlist[$field];
991  print '<input type="hidden" value="'.$forcedvalue.'" name="'.$keyname.'">';
992  }
993  print '</td>';
994  }
995  elseif ($fieldlist[$field] == 'lang')
996  {
997  print '<td>';
998  if (! empty($conf->global->MAIN_MULTILANGS))
999  {
1000  $selectedlang = GETPOSTISSET('langcode')?GETPOST('langcode', 'aZ09'):$langs->defaultlang;
1001  if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
1002  print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150');
1003  }
1004  else
1005  {
1006  if (! empty($obj->{$fieldlist[$field]}))
1007  {
1008  print $obj->{$fieldlist[$field]}.' - '.$langs->trans('Language_'.$obj->{$fieldlist[$field]});
1009  }
1010  $keyname=$fieldlist[$field];
1011  if ($keyname == 'lang') $keyname='langcode'; // Avoid conflict with lang param
1012  print '<input type="hidden" value="'.$obj->{$fieldlist[$field]}.'" name="'.$keyname.'">';
1013  }
1014  print '</td>';
1015  }
1016  // Le type de template
1017  elseif ($fieldlist[$field] == 'type_template')
1018  {
1019  print '<td>';
1020  if ($context == 'edit' && ! empty($obj->{$fieldlist[$field]}) && ! in_array($obj->{$fieldlist[$field]}, array_keys($elementList)))
1021  {
1022  // Current tempalte type is an unknown type, so we must keep it as it is.
1023  print '<input type="hidden" name="type_template" value="'.$obj->{$fieldlist[$field]}.'">';
1024  print $obj->{$fieldlist[$field]};
1025  }
1026  else
1027  {
1028  print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150 maxwidth100onsmartphone');
1029  }
1030  print '</td>';
1031  }
1032  elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1033  elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1034  elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1035  else
1036  {
1037  $size=''; $class=''; $classtd='';
1038  if ($fieldlist[$field]=='code') $class='maxwidth100';
1039  if ($fieldlist[$field]=='label') $class='maxwidth100';
1040  if ($fieldlist[$field]=='private') { $class='maxwidth50'; $classtd='center'; }
1041  if ($fieldlist[$field]=='position') { $class='maxwidth50'; $classtd='center'; }
1042  if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
1043  if ($fieldlist[$field]=='topic') $class='quatrevingtpercent';
1044  if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
1045 
1046  print '<td'.($classtd?' class="'.$classtd.'"':'').'>';
1047  if ($fieldlist[$field]=='private')
1048  {
1049  if (empty($user->admin))
1050  {
1051  print $form->selectyesno($fieldlist[$field], '1', 1);
1052  }
1053  else
1054  {
1055  //print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
1056  print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
1057  }
1058  }
1059  else
1060  {
1061  print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
1062  }
1063  print '</td>';
1064  }
1065  }
1066 }
1067 
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Classe permettant la generation du formulaire html d&#39;envoi de mail unitaire Usage: $formail = new For...
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
print
Draft customers invoices.
Definition: index.php:91
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: admin.lib.php:1730
Class to manage Dolibarr users.
Definition: user.class.php:41
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
if(! GETPOST('transkey', 'alphanohtml') &&! GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:43
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting a parameter.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
type
Definition: viewcat.php:284
fieldList($fieldlist, $obj='', $tabname='', $context='')
Show fields in insert/edit mode.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0)
Function to show navigation arrows into lists.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
static getAvailableSubstitKey($mode='formemail', $object=null)
Get list of substitution keys available for emails.
Class to manage a WYSIWYG editor.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.