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