dolibarr  21.0.0-alpha
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@open-dsi.fr>
12  * Copyright (C) 2015-2024 Ferran Marcet <fmarcet@2byte.es>
13  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14  * Copyright (C) 2018-2023 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 <https://www.gnu.org/licenses/>.
28  */
29 
36 // Load Dolibarr environment
37 require '../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
45 
46 // Load translation files required by the page
47 $langsArray = array("errors", "admin", "mails", "languages");
48 
49 if (isModEnabled('member')) {
50  $langsArray[] = 'members';
51 }
52 if (isModEnabled('eventorganization')) {
53  $langsArray[] = 'eventorganization';
54 }
55 
56 $langs->loadLangs($langsArray);
57 
58 $toselect = GETPOST('toselect', 'array');
59 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view';
60 $massaction = GETPOST('massaction', 'alpha');
61 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
62 $mode = GETPOST('mode', 'aZ09');
63 $optioncss = GETPOST('optioncss', 'alpha');
64 
65 $id = GETPOSTINT('id');
66 $rowid = GETPOST('rowid', 'alpha');
67 $search_label = GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)'
68 $search_type_template = GETPOST('search_type_template', 'alpha');
69 $search_lang = GETPOST('search_lang', 'alpha');
70 $search_fk_user = GETPOST('search_fk_user', 'intcomma');
71 $search_topic = GETPOST('search_topic', 'alpha');
72 $search_module = GETPOST('search_module', 'alpha');
73 
74 $acts = array();
75 $actl = array();
76 $acts[0] = "activate";
77 $acts[1] = "disable";
78 $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
79 $actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
80 
81 $listoffset = GETPOST('listoffset', 'alpha');
82 $listlimit = GETPOST('listlimit', 'alpha') > 0 ? GETPOST('listlimit', 'alpha') : 1000;
83 
84 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
85 $sortfield = GETPOST('sortfield', 'aZ09comma');
86 $sortorder = GETPOST('sortorder', 'aZ09comma');
87 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
88 if (empty($page) || $page == -1) {
89  $page = 0;
90 } // If $page is not defined, or '' or -1
91 $offset = $listlimit * $page;
92 $pageprev = $page - 1;
93 $pagenext = $page + 1;
94 
95 if (empty($sortfield)) {
96  $sortfield = 'type_template,lang,position,label';
97 }
98 if (empty($sortorder)) {
99  $sortorder = 'ASC';
100 }
101 
102 // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
103 $hookmanager->initHooks(array('emailtemplates'));
104 
105 
106 // Name of SQL tables of dictionaries
107 $tabname = array();
108 $tabname[25] = MAIN_DB_PREFIX."c_email_templates";
109 
110 // Nom des champs en resultat de select pour affichage du dictionnaire
111 $tabfield = array();
112 $tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,defaultfortype,content";
113 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
114  $tabfield[25] .= ',content_lines';
115 }
116 
117 // Nom des champs d'edition pour modification d'un enregistrement
118 $tabfieldvalue = array();
119 $tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
120 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
121  $tabfieldvalue[25] .= ',content_lines';
122 }
123 
124 // Nom des champs dans la table pour insertion d'un enregistrement
125 $tabfieldinsert = array();
126 $tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
127 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
128  $tabfieldinsert[25] .= ',content_lines';
129 }
130 $tabfieldinsert[25] .= ',entity'; // Must be at end because not into other arrays
131 
132 // Condition to show dictionary in setup page
133 $tabcond = array();
134 $tabcond[25] = true;
135 
136 // List of help for fields
137 // Set MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES to allow edit of template for lines
138 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
139 $formmail = new FormMail($db);
140 if (!getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
141  $tmp = FormMail::getAvailableSubstitKey('formemail');
142  $tmp['__(AnyTranslationKey)__'] = 'Translation';
143  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
144  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
145  foreach ($tmp as $key => $val) {
146  $helpsubstit .= $key.' -> '.$val.'<br>';
147  $helpsubstitforlines .= $key.' -> '.$val.'<br>';
148  }
149 } else {
150  $tmp = FormMail::getAvailableSubstitKey('formemailwithlines');
151  $tmp['__(AnyTranslationKey)__'] = 'Translation';
152  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
153  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
154  foreach ($tmp as $key => $val) {
155  $helpsubstit .= $key.' -> '.$val.'<br>';
156  }
157  $tmp = FormMail::getAvailableSubstitKey('formemailforlines');
158  foreach ($tmp as $key => $val) {
159  $helpsubstitforlines .= $key.' -> '.$val.'<br>';
160  }
161 }
162 
163 
164 $tabhelp = array();
165 $tabhelp[25] = array(
166  'label' => $langs->trans('EnterAnyCode'),
167  'type_template' => $langs->trans("TemplateForElement"),
168  'private' => $langs->trans("TemplateIsVisibleByOwnerOnly"),
169  'position' => $langs->trans("PositionIntoComboList"),
170  'topic' => '<span class="small">'.$helpsubstit.'</span>',
171  'email_from' => $langs->trans('ForceEmailFrom'),
172  'joinfiles' => $langs->trans('AttachMainDocByDefault'),
173  'defaultfortype' => $langs->trans("DefaultForTypeDesc"),
174  'content' => '<span class="small">'.$helpsubstit.'</span>',
175  'content_lines' => '<span class="small">'.$helpsubstitforlines.'</span>'
176 );
177 
178 
179 // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
180 $elementList = array();
181 // Add all and none after the sort
182 
183 $elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --';
184 $elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --';
185 $elementList['user'] = img_picto('', 'user', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToUser'));
186 if (isModEnabled('member') && $user->hasRight('adherent', 'lire')) {
187  $elementList['member'] = img_picto('', 'object_member', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToMember'));
188 }
189 if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
190  $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
191 }
192 if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
193  $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
194 }
195 if (isModEnabled("societe") && $user->hasRight('societe', 'contact', 'lire')) {
196  $elementList['contact'] = img_picto('', 'contact', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToContact'));
197 }
198 if (isModEnabled('project')) {
199  $elementList['project'] = img_picto('', 'project', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToProject'));
200 }
201 if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
202  $elementList['propal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
203 }
204 if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
205  $elementList['order_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
206 }
207 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
208  $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
209 }
210 if (isModEnabled("shipping")) {
211  $elementList['shipping_send'] = img_picto('', 'dolly', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
212 }
213 if (isModEnabled("reception")) {
214  $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendReception'));
215 }
216 if (isModEnabled('intervention')) {
217  $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
218 }
219 if (isModEnabled('supplier_proposal')) {
220  $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
221 }
222 if (isModEnabled("supplier_order") && ($user->hasRight('fournisseur', 'commande', 'lire') || $user->hasRight('supplier_order', 'read'))) {
223  $elementList['order_supplier_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
224 }
225 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
226  $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
227 }
228 if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
229  $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract'));
230 }
231 if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) {
232  $elementList['ticket_send'] = img_picto('', 'ticket', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToTicket'));
233 }
234 if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire')) {
235  $elementList['expensereport_send'] = img_picto('', 'trip', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToExpenseReport'));
236 }
237 if (isModEnabled('agenda')) {
238  $elementList['actioncomm_send'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
239 }
240 if (isModEnabled('eventorganization') && $user->hasRight('eventorganization', 'read')) {
241  $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
242 }
243 if (isModEnabled('partnership') && $user->hasRight('partnership', 'read')) {
244  $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership'));
245 }
246 
247 $parameters = array('elementList' => $elementList);
248 $reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks
249 if ($reshook == 0) {
250  foreach ($hookmanager->resArray as $item => $value) {
251  $elementList[$item] = $value;
252  }
253 }
254 
255 $id = 25;
256 
257 $acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
258 
259 // Security
260 if (!empty($user->socid)) {
261  accessforbidden();
262 }
263 
264 $permissiontoadd = 1;
265 $permissiontodelete = 1;
266 
267 
268 
269 /*
270  * Actions
271  */
272 
273 if (GETPOST('cancel', 'alpha')) {
274  $action = 'list';
275  $massaction = '';
276 }
277 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
278  $massaction = '';
279 }
280 
281 $parameters = array();
282 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
283 if ($reshook < 0) {
284  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
285 }
286 
287 if (empty($reshook)) {
288  // Selection of new fields
289  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
290 
291  // Purge search criteria
292  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
293  // All tests are required to be compatible with all browsers
294  $search_label = '';
295  $search_type_template = '';
296  $search_lang = '';
297  $search_fk_user = '';
298  $search_topic = '';
299  $search_module = '';
300  $toselect = array();
301  $search_array_options = array();
302  }
303 
304  // Actions add or modify an email template
305  if ((GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) && $permissiontoadd) {
306  $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
307  $listfieldinsert = explode(',', $tabfieldinsert[$id]);
308  $listfieldmodify = explode(',', $tabfieldinsert[$id]);
309  $listfieldvalue = explode(',', $tabfieldvalue[$id]);
310 
311  // Check that all fields are filled
312  $ok = 1;
313  foreach ($listfield as $f => $value) {
314  // Not mandatory fields
315  if (in_array($value, ['joinfiles', 'defaultfortype', 'content', 'content_lines', 'module'])) {
316  continue;
317  }
318 
319  // Rename some POST variables into a generic name
320  if (GETPOST('actionmodify', 'alpha') && $value == 'topic') {
321  $_POST['topic'] = GETPOST('topic-'.$rowid);
322  }
323 
324  if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') {
325  $ok = 0;
326  $fieldnamekey = $listfield[$f];
327  // We take translate key of field
328  if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
329  $fieldnamekey = 'Code';
330  }
331  if ($fieldnamekey == 'code') {
332  $fieldnamekey = 'Code';
333  }
334  if ($fieldnamekey == 'note') {
335  $fieldnamekey = 'Note';
336  }
337  if ($fieldnamekey == 'type_template') {
338  $fieldnamekey = 'TypeOfTemplate';
339  }
340  if ($fieldnamekey == 'fk_user') {
341  $fieldnamekey = 'Owner';
342  }
343  if ($fieldnamekey == 'private') {
344  $fieldnamekey = 'Private';
345  }
346  if ($fieldnamekey == 'position') {
347  $fieldnamekey = 'Position';
348  }
349  if ($fieldnamekey == 'topic') {
350  $fieldnamekey = 'Topic';
351  }
352 
353  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
354  $action = 'create';
355  }
356  }
357 
358  // If previous test is ok action is add, we add the line
359  if ($ok && GETPOST('actionadd')) {
360  // Add new entry
361  $sql = "INSERT INTO ".$tabname[$id]." (";
362  // List of fields
363  $sql .= $tabfieldinsert[$id];
364  $sql .= ", active, enabled)";
365  $sql .= " VALUES(";
366 
367  // List of values
368  $i = 0;
369  foreach ($listfieldinsert as $f => $value) {
370  $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] : "";
371  if ($value == 'lang') {
372  $keycode = 'langcode';
373  }
374  if (empty($keycode)) {
375  $keycode = $value;
376  }
377 
378  // Clean input variables
379  if ($value == 'entity') {
380  $_POST[$keycode] = $conf->entity;
381  }
382  if ($value == 'fk_user' && !($_POST[$keycode] > 0)) {
383  $_POST[$keycode] = '';
384  }
385  if ($value == 'private' && !is_numeric($_POST[$keycode])) {
386  $_POST[$keycode] = '0';
387  }
388  if ($value == 'position' && !is_numeric($_POST[$keycode])) {
389  $_POST[$keycode] = '1';
390  }
391  if ($value == 'defaultfortype' && !is_numeric($_POST[$keycode])) {
392  $_POST[$keycode] = '0';
393  }
394  //var_dump($keycode.' '.$value);
395 
396  if ($i) {
397  $sql .= ", ";
398  }
399  if (GETPOST($keycode) == '' && $keycode != 'langcode') {
400  $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work
401  } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
402  $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
403  } elseif ($keycode == 'fk_user') {
404  if (!$user->admin) { // A non admin user can only edit its own template
405  $sql .= " ".((int) $user->id);
406  } else {
407  $sql .= " ".(GETPOSTINT($keycode));
408  }
409  } elseif ($keycode == 'content') {
410  $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
411  } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position', 'entity'))) {
412  $sql .= GETPOSTINT($keycode);
413  } else {
414  $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
415  }
416  $i++;
417  }
418  $sql .= ", 1, 1)";
419 
420  dol_syslog("actionadd", LOG_DEBUG);
421  $result = $db->query($sql);
422  if ($result) { // Add is ok
423  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
424  $_POST = array('id' => $id); // Clean $_POST array, we keep only id
425  } else {
426  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
427  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
428  } else {
429  dol_print_error($db);
430  }
431  $action = 'create';
432  }
433  }
434 
435  // We modify the line
436  if ($ok && GETPOST('actionmodify')) {
437  $rowidcol = "rowid";
438 
439  // Modify entry
440  $sql = "UPDATE ".$tabname[$id]." SET ";
441  // Modify value of fields
442  $i = 0;
443  foreach ($listfieldmodify as $field) {
444  if ($field == 'entity') {
445  // entity not present on listfieldmodify array
446  $keycode = $field;
447  $_POST[$keycode] = $conf->entity;
448  } else {
449  $keycode = $listfieldvalue[$i];
450  }
451 
452  if ($field == 'lang') {
453  $keycode = 'langcode';
454  }
455  if (empty($keycode)) {
456  $keycode = $field;
457  }
458 
459  // Rename some POST variables into a generic name
460  if ($field == 'fk_user' && !(GETPOSTINT('fk_user') > 0)) {
461  $_POST['fk_user'] = '';
462  }
463  if ($field == 'topic') {
464  $_POST['topic'] = GETPOST('topic-'.$rowid);
465  }
466  if ($field == 'joinfiles') {
467  $_POST['joinfiles'] = GETPOST('joinfiles-'.$rowid);
468  }
469  if ($field == 'content') {
470  $_POST['content'] = GETPOST('content-'.$rowid, 'restricthtml');
471  }
472  if ($field == 'content_lines') {
473  $_POST['content_lines'] = GETPOST('content_lines-'.$rowid, 'restricthtml');
474  }
475 
476  if ($i) {
477  $sql .= ", ";
478  }
479  $sql .= $field."=";
480 
481  if (GETPOST($keycode) == '' || (!in_array($keycode, array('langcode', 'position', 'private', 'defaultfortype')) && !GETPOST($keycode))) {
482  $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
483  } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
484  $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
485  } elseif ($keycode == 'fk_user') {
486  if (!$user->admin) { // A non admin user can only edit its own template
487  $sql .= " ".((int) $user->id);
488  } else {
489  $sql .= " ".(GETPOSTINT($keycode));
490  }
491  } elseif ($keycode == 'content') {
492  $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
493  } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position'))) {
494  $sql .= GETPOSTINT($keycode);
495  } else {
496  $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
497  }
498  $i++;
499  }
500 
501  $sql .= " WHERE ".$db->escape($rowidcol)." = ".((int) $rowid);
502  if (!$user->admin) { // A non admin user can only edit its own template
503  $sql .= " AND fk_user = ".((int) $user->id);
504  }
505  //print $sql;exit;
506  dol_syslog("actionmodify", LOG_DEBUG);
507  //print $sql;
508  $resql = $db->query($sql);
509  if ($resql) {
510  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
511  } else {
512  setEventMessages($db->error(), null, 'errors');
513  $action = 'edit';
514  }
515  }
516  }
517 
518  if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { // delete
519  $rowidcol = "rowid";
520 
521  $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
522  if (!$user->admin) { // A non admin user can only edit its own template
523  $sql .= " AND fk_user = ".((int) $user->id);
524  }
525  dol_syslog("delete", LOG_DEBUG);
526  $result = $db->query($sql);
527  if (!$result) {
528  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
529  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
530  } else {
531  dol_print_error($db);
532  }
533  }
534  }
535 
536  // activate
537  if ($action == $acts[0] && $permissiontoadd) {
538  $rowidcol = "rowid";
539 
540  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE rowid = ".((int) $rowid);
541 
542  $result = $db->query($sql);
543  if (!$result) {
544  dol_print_error($db);
545  }
546  }
547 
548  // disable
549  if ($action == $acts[1] && $permissiontoadd) {
550  $rowidcol = "rowid";
551 
552  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE rowid = ".((int) $rowid);
553 
554  $result = $db->query($sql);
555  if (!$result) {
556  dol_print_error($db);
557  }
558  }
559 }
560 
561 
562 /*
563  * View
564  */
565 
566 $form = new Form($db);
567 
568 $now = dol_now();
569 
570 $formadmin = new FormAdmin($db);
571 
572 //$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
573 $help_url = '';
574 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
575  $title = $langs->trans("EMailsSetup");
576 } else {
577  $title = $langs->trans("EMailTemplates");
578 }
579 $morejs = array();
580 $morecss = array();
581 
582 $sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from,joinfiles, defaultfortype, content_lines, content, enabled, active";
583 $sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates";
584 $sql .= " WHERE entity IN (".getEntity('email_template').")";
585 if (!$user->admin) {
586  $sql .= " AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id)."))"; // Show only public and private to me
587  $sql .= " AND (active = 1 OR fk_user = ".((int) $user->id).")"; // Show only active or owned by me
588 }
589 if (!getDolGlobalInt('MAIN_MULTILANGS')) {
590  $sql .= " AND (lang = '".$db->escape($langs->defaultlang)."' OR lang IS NULL OR lang = '')";
591 }
592 if ($search_label) {
593  $sql .= natural_search('label', $search_label);
594 }
595 if ($search_type_template != '' && $search_type_template != '-1') {
596  $sql .= natural_search('type_template', $search_type_template);
597 }
598 if ($search_lang) {
599  $sql .= natural_search('lang', $search_lang);
600 }
601 if ($search_fk_user != '' && $search_fk_user != '-1') {
602  $sql .= natural_search('fk_user', $search_fk_user, 2);
603 }
604 if ($search_module) {
605  $sql .= natural_search('module', $search_module);
606 }
607 if ($search_topic) {
608  $sql .= natural_search('topic', $search_topic);
609 }
610 // If sort order is "country", we use country_code instead
611 if ($sortfield == 'country') {
612  $sortfield = 'country_code';
613 }
614 $sql .= $db->order($sortfield, $sortorder);
615 $sql .= $db->plimit($listlimit + 1, $offset);
616 //print $sql;
617 
618 // Output page
619 // --------------------------------------------------------------------
620 
621 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-admin page-mails_templates');
622 
623 $arrayofselected = is_array($toselect) ? $toselect : array();
624 
625 $param = '';
626 if (!empty($mode)) {
627  $param .= '&mode='.urlencode($mode);
628 }
629 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
630  $param .= '&contextpage='.urlencode($contextpage);
631 }
632 if ($limit > 0 && $limit != $conf->liste_limit) {
633  $param .= '&limit='.((int) $limit);
634 }
635 if (!empty($search) && is_array($search)) {
636  foreach ($search as $key => $val) {
637  if (is_array($search[$key]) && count($search[$key])) {
638  foreach ($search[$key] as $skey) {
639  if ($skey != '') {
640  $param .= '&search_'.$key.'[]='.urlencode($skey);
641  }
642  }
643  } elseif ($search[$key] != '') {
644  $param .= '&search_'.$key.'='.urlencode($search[$key]);
645  }
646  }
647 }
648 if ($optioncss != '') {
649  $param .= '&optioncss='.urlencode($optioncss);
650 }
651 // Add $param from extra fields
652 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
653 // Add $param from hooks
654 $parameters = array();
655 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
656 $param .= $hookmanager->resPrint;
657 
658 
659 $linkback = '';
660 $titlepicto = 'title_setup';
661 
662 
663 $url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create';
664 $newcardbutton = '';
665 $newcardbutton .= dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
666 
667 
668 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
669  print load_fiche_titre($title, '', $titlepicto);
670 } else {
671  print load_fiche_titre($title, $newcardbutton, $titlepicto);
672 }
673 
674 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
675  $head = email_admin_prepare_head();
676 
677  print dol_get_fiche_head($head, 'templates', '', -1);
678 
679  if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
680  print load_fiche_titre('', $newcardbutton, '');
681  }
682 }
683 
684 
685 // Confirm deletion of record
686 if ($action == 'delete') {
687  print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid).'&id='.((int) $id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
688 }
689 
690 
691 $fieldlist = explode(',', $tabfield[$id]);
692 
693 if ($action == 'create') {
694  // If data was already input, we define them in obj to populate input fields.
695  $obj = new stdClass();
696  $obj->label = GETPOST('label');
697  $obj->lang = GETPOST('lang');
698  $obj->type_template = GETPOST('type_template');
699  $obj->fk_user = GETPOSTINT('fk_user');
700  $obj->private = GETPOSTINT('private');
701  $obj->position = GETPOST('position');
702  $obj->topic = GETPOST('topic');
703  $obj->joinfiles = GETPOST('joinfiles');
704  $obj->defaultfortype = GETPOST('defaultfortype') ? 1 : 0;
705  $obj->content = GETPOST('content', 'restricthtml');
706 
707  // Form to add a new line
708  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
709  print '<input type="hidden" name="token" value="'.newToken().'">';
710  print '<input type="hidden" name="action" value="add">';
711  print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
712 
713  print '<div class="div-table-responsive-no-min">';
714  print '<table class="noborder centpercent">';
715 
716  // Line to enter new values (title)
717  print '<tr class="liste_titre">';
718  foreach ($fieldlist as $field => $value) {
719  // Determine le nom du champ par rapport aux noms possibles
720  // dans les dictionnaires de donnees
721  $valuetoshow = ucfirst($fieldlist[$field]); // Par default
722  $valuetoshow = $langs->trans($valuetoshow); // try to translate
723  $css = "left";
724  if ($fieldlist[$field] == 'module') {
725  $valuetoshow = '&nbsp;';
726  }
727  if ($fieldlist[$field] == 'fk_user') {
728  $valuetoshow = $langs->trans("Owner");
729  }
730  if ($fieldlist[$field] == 'lang') {
731  $valuetoshow = (!getDolGlobalInt('MAIN_MULTILANGS') ? '&nbsp;' : $langs->trans("Language"));
732  }
733  if ($fieldlist[$field] == 'type') {
734  $valuetoshow = $langs->trans("Type");
735  }
736  if ($fieldlist[$field] == 'position') {
737  $css = 'center';
738  }
739  if ($fieldlist[$field] == 'code') {
740  $valuetoshow = $langs->trans("Code");
741  }
742  if ($fieldlist[$field] == 'label') {
743  $valuetoshow = $langs->trans("Code");
744  }
745  if ($fieldlist[$field] == 'type_template') {
746  $valuetoshow = $langs->trans("TypeOfTemplate");
747  $css = "center";
748  }
749  if (in_array($fieldlist[$field], array('private', 'private', 'defaultfortype'))) {
750  $css = 'center';
751  }
752 
753  if ($fieldlist[$field] == 'topic') {
754  $valuetoshow = '';
755  }
756  if ($fieldlist[$field] == 'joinfiles') {
757  $valuetoshow = '';
758  }
759  if ($fieldlist[$field] == 'content') {
760  $valuetoshow = '';
761  }
762  if ($fieldlist[$field] == 'content_lines') {
763  $valuetoshow = '';
764  }
765  if ($valuetoshow != '') {
766  print '<th class="'.$css.'">';
767  if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
768  print '<a href="'.$tabhelp[$id][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
769  } elseif (!empty($tabhelp[$id][$value])) {
770  if (in_array($value, array('topic'))) {
771  print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
772  } else {
773  print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
774  }
775  } else {
776  print $valuetoshow;
777  }
778  print '</th>';
779  }
780  }
781  print '<th>';
782  print '<input type="hidden" name="id" value="'.$id.'">';
783  print '</th>';
784  print '</tr>';
785 
786  $tmpaction = 'create';
787  $parameters = array(
788  'fieldlist' => $fieldlist,
789  'tabname' => $tabname[$id]
790  );
791  $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
792  $error = $hookmanager->error;
793  $errors = $hookmanager->errors;
794 
795 
796  // Line to enter new values (input fields)
797  print '<tr class="oddeven">';
798 
799  if (empty($reshook)) {
800  if ($action == 'edit') {
801  fieldList($fieldlist, $obj, $tabname[$id], 'hide');
802  } else {
803  fieldList($fieldlist, $obj, $tabname[$id], 'add');
804  }
805  }
806  // Action column
807  print '<td class="right">';
808  print '</td>';
809  print "</tr>";
810 
811  print '<tr class="oddeven nodrag nodrop nohover"><td colspan="9">';
812 
813  // Show fields for topic, join files and body
814  $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content');
815  if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
816  $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content', 'content_lines');
817  }
818  foreach ($fieldsforcontent as $tmpfieldlist) {
819  // Topic of email
820  if ($tmpfieldlist == 'topic') {
821  print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
822  }
823  if ($tmpfieldlist == 'email_from') {
824  print $form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist);
825  }
826  if ($tmpfieldlist == 'joinfiles') {
827  print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
828  }
829  if ($tmpfieldlist == 'content') {
830  print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
831  }
832  if ($tmpfieldlist == 'content_lines') {
833  print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
834  }
835 
836  // Input field
837  if ($tmpfieldlist == 'topic') {
838  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
839  } elseif ($tmpfieldlist == 'email_from') {
840  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
841  } elseif ($tmpfieldlist == 'joinfiles') {
842  print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1);
843  } else {
844  $okforextended = true;
845  if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
846  $okforextended = false;
847  }
848  $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : ''), '', 400, 'dolibarr_mailings', 'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
849  print $doleditor->Create(1);
850  }
851  print '<br>';
852  }
853 
854  print '</tr>';
855 
856  print '</table>';
857 
858  if ($action != 'edit') {
859  print '<center>';
860  print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"> ';
861  print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
862  print '</center>';
863  }
864 
865  print '</div>';
866  print '</form>';
867 
868  print '<br><br><br>';
869 }
870 
871 // List of available record in database
872 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
873 $resql = $db->query($sql);
874 if (!$resql) {
875  dol_print_error($db);
876  exit;
877 }
878 
879 $num = $db->num_rows($resql);
880 
881 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
882 print '<input type="hidden" name="token" value="'.newToken().'">';
883 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
884 
885 print '<div class="div-table-responsive-no-min">';
886 print '<table class="noborder centpercent">';
887 
888 $i = 0;
889 
890 $param = '&id='.((int) $id);
891 if ($search_label) {
892  $param .= '&search_label='.urlencode($search_label);
893 }
894 if (!empty($search_lang) && $search_lang != '-1') {
895  $param .= '&search_lang='.urlencode($search_lang);
896 }
897 if ($search_type_template != '-1') {
898  $param .= '&search_type_template='.urlencode($search_type_template);
899 }
900 if ($search_fk_user > 0) {
901  $param .= '&search_fk_user='.urlencode($search_fk_user);
902 }
903 if ($search_module) {
904  $param .= '&search_module='.urlencode($search_module);
905 }
906 if ($search_topic) {
907  $param .= '&search_topic='.urlencode($search_topic);
908 }
909 
910 $paramwithsearch = $param;
911 if ($sortorder) {
912  $paramwithsearch .= '&sortorder='.urlencode($sortorder);
913 }
914 if ($sortfield) {
915  $paramwithsearch .= '&sortfield='.urlencode($sortfield);
916 }
917 if (GETPOST('from', 'alpha')) {
918  $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
919 }
920 
921 // There is several pages
922 if ($num > $listlimit) {
923  print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
924  print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
925  print '</td></tr>';
926 }
927 
928 
929 // Title line with search boxes
930 print '<tr class="liste_titre">';
931 // Action column
932 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
933  print '<td class="liste_titre center" width="64">';
934  $searchpicto = $form->showFilterButtons();
935  print $searchpicto;
936  print '</td>';
937 }
938 foreach ($fieldlist as $field => $value) {
939  if ($value == 'module') {
940  print '<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).'"></td>';
941  } elseif ($value == 'label') {
942  print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).'"></td>';
943  } elseif ($value == 'lang') {
944  print '<td class="liste_titre">';
945  print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
946  print '</td>';
947  } elseif ($value == 'fk_user') {
948  print '<td class="liste_titre">';
949  print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth100', 1);
950  print '</td>';
951  } elseif ($value == 'topic') {
952  print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
953  } elseif ($value == 'type_template') {
954  print '<td class="liste_titre center">';
955  // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
956  print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth125', 1, '', 0, 1);
957  print '</td>';
958  } elseif (!in_array($value, array('content', 'content_lines'))) {
959  print '<td class="liste_titre"></td>';
960  }
961 }
962 /*if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
963  print '<td class="liste_titre"></td>';
964 }*/
965 // Status
966 print '<td></td>';
967 // Action column
968 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
969  print '<td class="liste_titre center" width="64">';
970  $searchpicto = $form->showFilterButtons();
971  print $searchpicto;
972  print '</td>';
973 }
974 print '</tr>';
975 
976 // Title of lines
977 print '<tr class="liste_titre">';
978 // Action column
979 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
980  print getTitleFieldOfList('');
981 }
982 foreach ($fieldlist as $field => $value) {
983  $showfield = 1; // By default
984  $css = "left";
985  $sortable = 1;
986  $valuetoshow = '';
987  $forcenowrap = 1;
988  /*
989  $tmparray=getLabelOfField($fieldlist[$field]);
990  $showfield=$tmp['showfield'];
991  $valuetoshow=$tmp['valuetoshow'];
992  $css=$tmp['align'];
993  $sortable=$tmp['sortable'];
994  */
995  $valuetoshow = ucfirst($fieldlist[$field]); // By default
996  $valuetoshow = $langs->trans($valuetoshow); // try to translate
997  if ($fieldlist[$field] == 'module') {
998  $css = 'tdoverflowmax100';
999  }
1000  if ($fieldlist[$field] == 'fk_user') {
1001  $valuetoshow = $langs->trans("Owner");
1002  }
1003  if ($fieldlist[$field] == 'lang') {
1004  $valuetoshow = $langs->trans("Language");
1005  }
1006  if ($fieldlist[$field] == 'type') {
1007  $valuetoshow = $langs->trans("Type");
1008  }
1009  if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
1010  $valuetoshow = $langs->trans("Code");
1011  }
1012  if ($fieldlist[$field] == 'type_template') {
1013  $css = 'center';
1014  $valuetoshow = $langs->trans("TypeOfTemplate");
1015  }
1016  if ($fieldlist[$field] == 'private') {
1017  $css = 'center';
1018  }
1019  if ($fieldlist[$field] == 'position') {
1020  $css = 'center';
1021  }
1022 
1023  if ($fieldlist[$field] == 'joinfiles') {
1024  $valuetoshow = $langs->trans("FilesAttachedToEmail");
1025  $css = 'center';
1026  $forcenowrap = 0;
1027  }
1028  if ($fieldlist[$field] == 'content') {
1029  $valuetoshow = $langs->trans("Content");
1030  $showfield = 0;
1031  }
1032  if ($fieldlist[$field] == 'content_lines') {
1033  $valuetoshow = $langs->trans("ContentForLines");
1034  $showfield = 0;
1035  }
1036 
1037  // Show fields
1038  if ($showfield) {
1039  if (!empty($tabhelp[$id][$value])) {
1040  if (in_array($value, array('topic'))) {
1041  $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
1042  } else {
1043  $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
1044  }
1045  }
1046  $sortfieldtouse = ($sortable ? $fieldlist[$field] : '');
1047  if ($sortfieldtouse == 'type_template') {
1048  $sortfieldtouse .= ',lang,position,label';
1049  }
1050  print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' ');
1051  }
1052 }
1053 
1054 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
1055 // Action column
1056 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1057  print getTitleFieldOfList('');
1058 }
1059 print '</tr>';
1060 
1061 if ($num) {
1062  $nbqualified = 0;
1063 
1064  // Lines with values
1065  while ($i < $num) {
1066  $obj = $db->fetch_object($resql);
1067 
1068  if ($obj) {
1069  if (($action == 'edit' || $action == 'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1070  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1071 
1072  $tmpaction = 'edit';
1073  $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
1074  $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1075  $error = $hookmanager->error;
1076  $errors = $hookmanager->errors;
1077 
1078  // Action column
1079  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1080  print '<td class="center">';
1081  print '<input type="hidden" name="page" value="'.$page.'">';
1082  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1083  if ($action == 'edit') {
1084  print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1085  }
1086  print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1087  print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1088  print '</td>';
1089  }
1090  // Show main fields
1091  if (empty($reshook)) {
1092  fieldList($fieldlist, $obj, $tabname[$id], $action);
1093  }
1094  // Action column
1095  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1096  print '<td class="center">';
1097  print '<input type="hidden" name="page" value="'.$page.'">';
1098  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1099  if ($action == 'edit') {
1100  print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1101  }
1102  print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1103  print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1104  print '</td>';
1105  }
1106  print "</tr>\n";
1107 
1108  print '<tr class="oddeven nohover" id="tr-aaa-'.$rowid.'">';
1109  print '<td colspan="10">';
1110 
1111  $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content');
1112  if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
1113  $fieldsforcontent[] = 'content_lines';
1114  }
1115  foreach ($fieldsforcontent as $tmpfieldlist) {
1116  $showfield = 1;
1117  $css = "left";
1118  $valuetoshow = $obj->$tmpfieldlist;
1119 
1120  $class = 'tddict';
1121  // Show value for field
1122  if ($showfield) {
1123  // Show line for topic, joinfiles and content
1124  if ($tmpfieldlist == 'topic') {
1125  print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1126  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1127  print '<br>'."\n";
1128  }
1129  if ($tmpfieldlist == 'email_from') {
1130  print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1131  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1132  print '<br>'."\n";
1133  }
1134  if ($tmpfieldlist == 'joinfiles') {
1135  print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1136  print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, ($action != 'edit'), 0, 1);
1137  print '<br>'."\n";
1138  }
1139 
1140  if ($tmpfieldlist == 'content') {
1141  print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
1142  $okforextended = true;
1143  if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1144  $okforextended = false;
1145  }
1146  $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%', ($action != 'edit' ? 1 : 0));
1147  print $doleditor->Create(1);
1148  }
1149  if ($tmpfieldlist == 'content_lines') {
1150  print '<br>'."\n";
1151  print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
1152  $okforextended = true;
1153  if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1154  $okforextended = false;
1155  }
1156  $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
1157  print $doleditor->Create(1);
1158  }
1159  }
1160  }
1161  print '</td>';
1162  print '<td></td>';
1163  print '<td></td>';
1164 
1165  print "</tr>\n";
1166 
1167  $nbqualified++;
1168  } else {
1169  // If template is for a module, check module is enabled.
1170  if ($obj->module) {
1171  $tempmodulekey = $obj->module;
1172  if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) {
1173  $i++;
1174  continue;
1175  }
1176  }
1177 
1178  $keyforobj = 'type_template';
1179  if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1180  $i++;
1181  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)
1182  }
1183  // Test on 'enabled'
1184  if (! (int) dol_eval($obj->enabled, 1, 1, '1')) {
1185  $i++;
1186  continue; // Email template not qualified
1187  }
1188 
1189  $nbqualified++;
1190 
1191  // Can an entry be erased or disabled ?
1192  $iserasable = 1;
1193  $canbedisabled = 1;
1194  $canbemodified = 1; // true by default
1195  if (!$user->admin && $obj->fk_user != $user->id) {
1196  $iserasable = 0;
1197  $canbedisabled = 0;
1198  $canbemodified = 0;
1199  }
1200 
1201  $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).(!empty($obj->code) ? '&code='.urlencode($obj->code) : '');
1202  if ($param) {
1203  $url .= '&'.$param;
1204  }
1205 
1206  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1207 
1208  // Action column - Modify link / Delete link
1209  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1210  print '<td class="center nowraponall" width="64">';
1211  if ($canbemodified) {
1212  print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1213  } else {
1214  print '<a class="reposition editfielda" href="'.$url.'&action=preview&token='.newToken().'">'.img_view().'</a>';
1215  }
1216  if ($iserasable) {
1217  print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
1218  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1219  }
1220  print '</td>';
1221  }
1222 
1223  $tmpaction = 'view';
1224  $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]);
1225  $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1226 
1227  $error = $hookmanager->error;
1228  $errors = $hookmanager->errors;
1229 
1230  if (empty($reshook)) {
1231  foreach ($fieldlist as $field => $value) {
1232  if (in_array($fieldlist[$field], array('content', 'content_lines'))) {
1233  continue;
1234  }
1235  $showfield = 1;
1236  $css = "";
1237  $class = "tddict";
1238  $title = '';
1239  $tmpvar = $fieldlist[$field];
1240  $valuetoshow = $obj->$tmpvar;
1241  if ($value == 'label' || $value == 'topic') {
1242  if ($langs->trans($valuetoshow) != $valuetoshow) {
1243  $valuetoshow = $langs->trans($valuetoshow);
1244  }
1245  $valuetoshow = dol_escape_htmltag($valuetoshow);
1246  }
1247  if ($value == 'label') {
1248  $class .= ' tdoverflowmax200';
1249  }
1250  if ($value == 'topic') {
1251  $class .= ' tdoverflowmax200 small';
1252  }
1253  if ($value == 'type_template') {
1254  $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1255  $css = "center tdoverflowmax150";
1256  }
1257  if ($value == 'lang' && $valuetoshow) {
1258  $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
1259  $class .= ' tdoverflowmax100';
1260  }
1261  if ($value == 'fk_user') {
1262  if ($valuetoshow > 0) {
1263  $fuser = new User($db);
1264  $fuser->fetch($valuetoshow);
1265  $valuetoshow = $fuser->getNomUrl(-1);
1266  $class .= ' tdoverflowmax100';
1267  }
1268  }
1269  if ($value == 'private') {
1270  $css = "center";
1271  if ($valuetoshow) {
1272  $valuetoshow = yn($valuetoshow);
1273  } else {
1274  $valuetoshow = '';
1275  }
1276  }
1277  if ($value == 'position') {
1278  $css = "center";
1279  }
1280  if (in_array($value, array('joinfiles', 'defaultfortype'))) {
1281  $css = "center";
1282  if ($valuetoshow) {
1283  //$valuetoshow = yn(1);
1284  $valuetoshow = '<input type="checkbox" checked="checked" disabled>';
1285  } else {
1286  $valuetoshow = '';
1287  }
1288  }
1289  if ($css) {
1290  $class .= ' '.$css;
1291  }
1292 
1293  // Show value for field
1294  if ($showfield) {
1295  print '<!-- '.$fieldlist[$field].' -->';
1296  print '<td class="'.$class.'"';
1297  if (in_array($value, array('code', 'label', 'topic'))) {
1298  print ' title="'.dol_escape_htmltag($valuetoshow).'"';
1299  }
1300  print '>';
1301  print $valuetoshow;
1302  print '</td>';
1303  }
1304  }
1305  }
1306 
1307  // Status / Active
1308  print '<td class="center nowrap">';
1309  if ($canbedisabled) {
1310  print '<a class="reposition" href="'.$url.'&action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
1311  } else {
1312  print '<span class="opacitymedium">'.$actl[$obj->active].'</span>';
1313  }
1314  print "</td>";
1315 
1316  // Action column - Modify link / Delete link
1317  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1318  print '<td class="center nowraponall" width="64">';
1319  if ($canbemodified) {
1320  print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1321  }
1322  if ($iserasable) {
1323  print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
1324  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1325  }
1326  print '</td>';
1327  }
1328 
1329  print "</tr>\n";
1330  }
1331  }
1332 
1333  $i++;
1334  }
1335 }
1336 
1337 // If no record found
1338 if ($nbqualified == 0) {
1339  $colspan = 12;
1340  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1341 }
1342 
1343 print '</table>';
1344 print '</div>';
1345 
1346 print '</form>';
1347 
1348 
1349 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
1350  print dol_get_fiche_end();
1351 }
1352 
1353 
1354 // End of page
1355 llxFooter();
1356 $db->close();
1357 
1358 
1368 function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
1369 {
1370  global $langs, $user, $db;
1371  global $form;
1372  global $elementList;
1373 
1374  $formadmin = new FormAdmin($db);
1375 
1376  foreach ($fieldlist as $field => $value) {
1377  //print $value;
1378  if ($value == 'module') {
1379  print '<td></td>';
1380  } elseif ($value == 'fk_user') {
1381  print '<td>';
1382  if ($user->admin && $context != 'preview') {
1383  print $form->select_dolusers(empty($obj->$value) ? '' : $obj->$value, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100');
1384  } else {
1385  if ($context == 'add') { // I am not admin and we show the add form
1386  print $user->getNomUrl(-1); // Me
1387  $forcedvalue = $user->id;
1388  } else {
1389  if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1390  $fuser = new User($db);
1391  $fuser->fetch($obj->$value);
1392  print $fuser->getNomUrl(-1);
1393  $forcedvalue = $fuser->id;
1394  } else {
1395  $forcedvalue = $obj->$value;
1396  }
1397  }
1398  $keyname = $value;
1399  print '<input type="hidden" value="'.$forcedvalue.'" name="'.$keyname.'">';
1400  }
1401  print '</td>';
1402  } elseif ($value == 'lang') {
1403  print '<td>';
1404  if (getDolGlobalInt('MAIN_MULTILANGS') && $context != 'preview') {
1405  $selectedlang = GETPOSTISSET('langcode') ? GETPOST('langcode', 'aZ09') : $langs->defaultlang;
1406  if ($context == 'edit') {
1407  $selectedlang = $obj->lang;
1408  }
1409  print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth100');
1410  } else {
1411  if (!empty($obj->lang)) {
1412  print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang);
1413  }
1414  $keyname = $value;
1415  if ($keyname == 'lang') {
1416  $keyname = 'langcode'; // Avoid conflict with lang param
1417  }
1418  print '<input type="hidden" value="'.(empty($obj->lang) ? '' : $obj->lang).'" name="'.$keyname.'">';
1419  }
1420  print '</td>';
1421  } elseif ($value == 'type_template') {
1422  // Le type de template
1423  print '<td class="center">';
1424  if (($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) || $context == 'preview') {
1425  // Current template type is an unknown type, so we must keep it as it is.
1426  print '<input type="hidden" name="type_template" value="'.$obj->type_template.'">';
1427  print $obj->type_template;
1428  } else {
1429  print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template : ''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1);
1430  }
1431  print '</td>';
1432  } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1433  //print '<td></td>';
1434  } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1435  print '<td></td>';
1436  } elseif ($context == 'preview' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1437  print '<td></td>';
1438  } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1439  //print '<td></td>';
1440  } else {
1441  $size = '';
1442  $class = '';
1443  $classtd = '';
1444  if ($value == 'code') {
1445  $class = 'maxwidth100';
1446  }
1447  if ($value == 'label') {
1448  $class = 'maxwidth200';
1449  }
1450  if ($value == 'private') {
1451  $class = 'maxwidth50';
1452  $classtd = 'center';
1453  }
1454  if ($value == 'position') {
1455  $class = 'maxwidth50 center';
1456  $classtd = 'center';
1457  }
1458  if ($value == 'topic') {
1459  $class = 'quatrevingtpercent';
1460  }
1461  if ($value == 'defaultfortype') {
1462  $class = 'width25 center';
1463  $classtd = 'center';
1464  }
1465 
1466  print '<td'.($classtd ? ' class="'.$classtd.'"' : '').'>';
1467  if ($value == 'private' && $context != 'preview') {
1468  if (empty($user->admin)) {
1469  // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1470  print $form->selectyesno($value, '1', 1);
1471  } else {
1472  // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1473  print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1);
1474  }
1475  } else {
1476  print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'"'.($context == 'preview' ? ' disabled' : '').'>';
1477  }
1478  print '</td>';
1479  }
1480  }
1481 }
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
email_admin_prepare_head()
Return array head with list of tabs to view object information.
Definition: admin.lib.php:2068
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
Class to manage a WYSIWYG editor.
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
static getAvailableSubstitKey($mode='formemail', $object=null)
Get list of substitution keys available for emails.
Class to manage Dolibarr users.
Definition: user.class.php:50
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:751
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
fieldList($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.