dolibarr 22.0.5
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-2025 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$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}
256if (isModEnabled('product') && !empty($user->rights->produit->lire)) {
257 $elementList['product_send'] = img_picto('', 'product', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('Product'));
258}
259
260$parameters = array('elementList' => $elementList);
261$reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks
262if ($reshook == 0) {
263 foreach ($hookmanager->resArray as $item => $value) {
264 $elementList[$item] = $value;
265 }
266}
267
268$error = 0;
269
270$acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
271
272// Security
273if (!empty($user->socid)) {
275}
276
277$permissiontoadd = 1;
278$permissiontoedit = ($user->admin ? 1 : 0);
279$permissiontodelete = ($user->admin ? 1 : 0);
280if ($rowid > 0) {
281 $tmpmailtemplate = new ModelMail($db);
282 $tmpmailtemplate->fetch($rowid);
283 if ($tmpmailtemplate->fk_user == $user->id) {
284 $permissiontoedit = 1;
285 $permissiontodelete = 1;
286 }
287}
288
289
290/*
291 * Actions
292 */
293
294if (GETPOST('cancel', 'alpha') || GETPOST('actioncancel', 'alpha')) {
295 $action = 'list';
296 $massaction = '';
297
298 if (!empty($backtopage)) {
299 header("Location: ".$backtopage);
300 exit(1);
301 }
302}
303if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
304 $massaction = '';
305}
306
307$parameters = array();
308$object = null;
309$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
310if ($reshook < 0) {
311 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
312}
313
314if (empty($reshook)) {
315 // Selection of new fields
316 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
317
318 // Purge search criteria
319 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
320 // All tests are required to be compatible with all browsers
321 $search_label = '';
322 $search_type_template = '';
323 $search_lang = '';
324 $search_fk_user = '';
325 $search_topic = '';
326 $search_module = '';
327 $toselect = array();
328 $search_array_options = array();
329 }
330
331 // Actions add or modify an email template
332 if ((GETPOST('actionadd', 'alpha') && $permissiontoadd) || (GETPOST('actionmodify', 'alpha') && $permissiontoedit)) {
333 $listfield = explode(',', str_replace(' ', '', $tabfield[25]));
334 $listfieldinsert = explode(',', $tabfieldinsert[25]);
335 $listfieldmodify = explode(',', $tabfieldinsert[25]);
336 $listfieldvalue = explode(',', $tabfieldvalue[25]);
337
338 // Check that all fields are filled
339 $ok = 1;
340 foreach ($listfield as $f => $value) {
341 // Not mandatory fields
342 if (in_array($value, ['joinfiles', 'defaultfortype', 'content', 'content_lines', 'module'])) {
343 continue;
344 }
345
346 // Rename some POST variables into a generic name
347 if (GETPOST('actionmodify', 'alpha') && $value == 'topic') {
348 $_POST['topic'] = GETPOST('topic-'.$rowid);
349 }
350
351 if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') {
352 $ok = 0;
353 $fieldnamekey = $listfield[$f];
354 // We take translate key of field
355 if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
356 $fieldnamekey = 'Code';
357 }
358 if ($fieldnamekey == 'code') {
359 $fieldnamekey = 'Code';
360 }
361 if ($fieldnamekey == 'note') {
362 $fieldnamekey = 'Note';
363 }
364 if ($fieldnamekey == 'type_template') {
365 $fieldnamekey = 'TypeOfTemplate';
366 }
367 if ($fieldnamekey == 'fk_user') {
368 $fieldnamekey = 'Owner';
369 }
370 if ($fieldnamekey == 'private') {
371 $fieldnamekey = 'Private';
372 }
373 if ($fieldnamekey == 'position') {
374 $fieldnamekey = 'Position';
375 }
376 if ($fieldnamekey == 'topic') {
377 $fieldnamekey = 'Topic';
378 }
379
380 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
381 $action = 'create';
382 }
383 }
384
385 // If previous test is ok action is add, we add the line
386 if ($ok && GETPOST('actionadd')) {
387 // Add new entry
388 $sql = "INSERT INTO ".$tabname[25]." (";
389 // List of fields
390 $sql .= $tabfieldinsert[25];
391 $sql .= ", active, enabled)";
392 $sql .= " VALUES(";
393
394 // List of values
395 $i = 0;
396 foreach ($listfieldinsert as $f => $value) {
397 $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] : "";
398 if ($value == 'lang') {
399 $keycode = 'langcode';
400 }
401 if (empty($keycode)) {
402 $keycode = $value;
403 }
404
405 // Clean input variables
406 if ($value == 'entity') {
407 $_POST[$keycode] = $conf->entity;
408 }
409 if ($value == 'fk_user' && !($_POST[$keycode] > 0)) {
410 $_POST[$keycode] = '';
411 }
412 if ($value == 'private' && !is_numeric($_POST[$keycode])) {
413 $_POST[$keycode] = '0';
414 }
415 if ($value == 'position' && !is_numeric($_POST[$keycode])) {
416 $_POST[$keycode] = '1';
417 }
418 if ($value == 'defaultfortype' && !is_numeric($_POST[$keycode])) {
419 $_POST[$keycode] = '0';
420 }
421 //var_dump($keycode.' '.$value);
422
423 if ($i) {
424 $sql .= ", ";
425 }
426 if (GETPOST($keycode) == '' && $keycode != 'langcode') {
427 $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work
428 } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
429 $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
430 } elseif ($keycode == 'fk_user') {
431 if (!$user->admin) { // A non admin user can only edit its own template
432 $sql .= " ".((int) $user->id);
433 } else {
434 $sql .= " ".(GETPOSTINT($keycode));
435 }
436 } elseif ($keycode == 'content') {
437 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
438 } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position', 'entity'))) {
439 $sql .= GETPOSTINT($keycode);
440 } else {
441 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
442 }
443 $i++;
444 }
445 $sql .= ", 1, 1)";
446
447 dol_syslog("actionadd", LOG_DEBUG);
448 $result = $db->query($sql);
449 if ($result) { // Add is ok
450 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
451 $_POST = array('id' => 25); // Clean $_POST array, we keep only id
452
453 if (!empty($backtopage)) {
454 header("Location: ".$backtopage);
455 exit(1);
456 }
457 } else {
458 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
459 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
460 } else {
461 dol_print_error($db);
462 }
463 $action = 'create';
464 }
465 }
466
467 // We modify the line
468 if ($ok && GETPOST('actionmodify')) {
469 $rowidcol = "rowid";
470
471 if (GETPOSTINT('fk_user') <= 0 && GETPOST('private')) {
472 setEventMessages($langs->trans("AnOwnerMustBeSetIfEmailTemplateIsPrivate"), null, 'errors');
473 $error++;
474 $action = 'edit';
475 }
476
477 if (!$error) {
478 // Modify entry
479 $sql = "UPDATE ".$tabname[25]." SET ";
480 // Modify value of fields
481 $i = 0;
482 foreach ($listfieldmodify as $field) {
483 if ($field == 'entity') {
484 // entity not present on listfieldmodify array
485 $keycode = $field;
486 $_POST[$keycode] = $conf->entity;
487 } else {
488 $keycode = $listfieldvalue[$i];
489 }
490
491 if ($field == 'lang') {
492 $keycode = 'langcode';
493 }
494 if (empty($keycode)) {
495 $keycode = $field;
496 }
497
498 // Rename some POST variables into a generic name
499 if ($field == 'fk_user' && !(GETPOSTINT('fk_user') > 0)) {
500 $_POST['fk_user'] = '';
501 }
502 if ($field == 'topic') {
503 $_POST['topic'] = GETPOST('topic-'.$rowid);
504 }
505 if ($field == 'joinfiles') {
506 $_POST['joinfiles'] = GETPOST('joinfiles-'.$rowid);
507 }
508 if ($field == 'content') {
509 $_POST['content'] = GETPOST('content-'.$rowid, 'restricthtml');
510 }
511 if ($field == 'content_lines') {
512 $_POST['content_lines'] = GETPOST('content_lines-'.$rowid, 'restricthtml');
513 }
514 if ($field == 'email_from') {
515 $_POST['email_from'] = GETPOST('email_from-'.$rowid, 'restricthtml');
516 }
517
518 if ($i) {
519 $sql .= ", ";
520 }
521 $sql .= $field."=";
522
523 if (GETPOST($keycode) == '' || (!in_array($keycode, array('langcode', 'position', 'private', 'defaultfortype')) && !GETPOST($keycode))) {
524 $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
525 } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
526 $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
527 } elseif ($keycode == 'fk_user') {
528 if (!$user->admin) { // A non admin user can only edit its own template
529 $sql .= " ".((int) $user->id);
530 } else {
531 $sql .= " ".(GETPOSTINT($keycode));
532 }
533 } elseif ($keycode == 'content') {
534 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
535 } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position'))) {
536 $sql .= GETPOSTINT($keycode);
537 } else {
538 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
539 }
540 $i++;
541 }
542
543 $sql .= " WHERE ".$db->escape($rowidcol)." = ".((int) $rowid);
544 if (!$user->admin) { // A non admin user can only edit its own template
545 $sql .= " AND fk_user = ".((int) $user->id);
546 }
547 //print $sql;exit;
548 dol_syslog("actionmodify", LOG_DEBUG);
549
550 //print $sql;
551 $resql = $db->query($sql);
552 if (!$resql) {
553 $error++;
554 setEventMessages($db->error(), null, 'errors');
555 $action = 'edit';
556 }
557 }
558
559 if (!$error) {
560 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
561 }
562 }
563 }
564
565 if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { // delete
566 $rowidcol = "rowid";
567
568 $sql = "DELETE from ".$tabname[25]." WHERE ".$rowidcol." = ".((int) $rowid);
569 if (!$user->admin) { // A non admin user can only edit its own template
570 $sql .= " AND fk_user = ".((int) $user->id);
571 }
572 dol_syslog("delete", LOG_DEBUG);
573 $result = $db->query($sql);
574 if (!$result) {
575 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
576 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
577 } else {
578 dol_print_error($db);
579 }
580 }
581 }
582
583 // activate
584 if ($action == $acts[0] && $permissiontoedit) {
585 $rowidcol = "rowid";
586
587 $sql = "UPDATE ".$tabname[25]." SET active = 1 WHERE rowid = ".((int) $rowid);
588
589 $result = $db->query($sql);
590 if (!$result) {
591 dol_print_error($db);
592 }
593 }
594
595 // disable
596 if ($action == $acts[1] && $permissiontoedit) {
597 $rowidcol = "rowid";
598
599 $sql = "UPDATE ".$tabname[25]." SET active = 0 WHERE rowid = ".((int) $rowid);
600
601 $result = $db->query($sql);
602 if (!$result) {
603 dol_print_error($db);
604 }
605 }
606}
607
608
609/*
610 * View
611 */
612
613$form = new Form($db);
614$formadmin = new FormAdmin($db);
615
616$now = dol_now();
617
618//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
619$help_url = '';
620if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
621 $title = $langs->trans("EMailsSetup");
622} else {
623 $title = $langs->trans("EMailTemplates");
624}
625$morejs = array();
626$morecss = array();
627
628$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from,joinfiles, defaultfortype, content_lines, content, enabled, active";
629$sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates";
630$sql .= " WHERE entity IN (".getEntity('email_template').")";
631if (!$user->admin) {
632 $sql .= " AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id)."))"; // Show only public and private to me
633 $sql .= " AND (active = 1 OR fk_user = ".((int) $user->id).")"; // Show only active or owned by me
634}
635if (!getDolGlobalInt('MAIN_MULTILANGS')) {
636 $sql .= " AND (lang = '".$db->escape($langs->defaultlang)."' OR lang IS NULL OR lang = '')";
637}
638if ($search_label) {
639 $sql .= natural_search('label', $search_label);
640}
641if ($search_type_template != '' && $search_type_template != '-1') {
642 $sql .= natural_search('type_template', $search_type_template);
643}
644if ($search_lang) {
645 $sql .= natural_search('lang', $search_lang);
646}
647if ($search_fk_user != '' && $search_fk_user != '-1') {
648 $sql .= natural_search('fk_user', $search_fk_user, 2);
649}
650if ($search_module) {
651 $sql .= natural_search('module', $search_module);
652}
653if ($search_topic) {
654 $sql .= natural_search('topic', $search_topic);
655}
656// If sort order is "country", we use country_code instead
657if ($sortfield == 'country') {
658 $sortfield = 'country_code';
659}
660$sql .= $db->order($sortfield, $sortorder);
661$sql .= $db->plimit($listlimit + 1, $offset);
662//print $sql;
663
664// Output page
665// --------------------------------------------------------------------
666
667llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-admin page-mails_templates');
668
669$arrayofselected = is_array($toselect) ? $toselect : array();
670
671$param = '';
672if (!empty($mode)) {
673 $param .= '&mode='.urlencode($mode);
674}
675if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
676 $param .= '&contextpage='.urlencode($contextpage);
677}
678if ($limit > 0 && $limit != $conf->liste_limit) {
679 $param .= '&limit='.((int) $limit);
680}
681if (!empty($search) && is_array($search)) {
682 foreach ($search as $key => $val) {
683 if (is_array($search[$key]) && count($search[$key])) {
684 foreach ($search[$key] as $skey) {
685 if ($skey != '') {
686 $param .= '&search_'.$key.'[]='.urlencode($skey);
687 }
688 }
689 } elseif ($search[$key] != '') {
690 $param .= '&search_'.$key.'='.urlencode($search[$key]);
691 }
692 }
693}
694if ($optioncss != '') {
695 $param .= '&optioncss='.urlencode($optioncss);
696}
697// Add $param from extra fields
698include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
699// Add $param from hooks
700$parameters = array();
701$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
702$param .= $hookmanager->resPrint;
703
704
705$linkback = '';
706$titlepicto = 'title_setup';
707
708
709$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create';
710$newcardbutton = '';
711$newcardbutton .= dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', (int) $permissiontoadd);
712
713
714if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
715 print load_fiche_titre($title, '', $titlepicto);
716} else {
717 print load_fiche_titre($title, $newcardbutton, $titlepicto);
718}
719
720if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
721 $head = email_admin_prepare_head();
722
723 print dol_get_fiche_head($head, 'templates', '', -1);
724
725 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
726 print load_fiche_titre('', $newcardbutton, '');
727 }
728}
729
730
731// Confirm deletion of record
732if ($action == 'delete') {
733 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);
734}
735
736
737$fieldlist = explode(',', $tabfield[25]);
738
739if ($action == 'create') {
740 // If data was already input, we define them in obj to populate input fields.
741 $obj = new stdClass();
742 $obj->label = GETPOST('label');
743 $obj->lang = GETPOST('lang');
744 $obj->type_template = GETPOST('type_template');
745 $obj->fk_user = GETPOSTINT('fk_user');
746 $obj->private = GETPOSTINT('private');
747 $obj->position = GETPOST('position');
748 $obj->topic = GETPOST('topic');
749 $obj->joinfiles = GETPOST('joinfiles');
750 $obj->defaultfortype = GETPOST('defaultfortype') ? 1 : 0;
751 $obj->content = GETPOST('content', 'restricthtml');
752
753 // Form to add a new line
754 print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
755 print '<input type="hidden" name="token" value="'.newToken().'">';
756 print '<input type="hidden" name="action" value="add">';
757 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
758 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
759
760 print '<div class="div-table-responsive-no-min">';
761 print '<table class="noborder centpercent">';
762
763 // Line to enter new values (title)
764 print '<tr class="liste_titre">';
765 foreach ($fieldlist as $field => $value) {
766 // Determine le nom du champ par rapport aux noms possibles
767 // dans les dictionnaires de donnees
768 $valuetoshow = ucfirst($fieldlist[$field]); // Par default
769 $valuetoshow = $langs->trans($valuetoshow); // try to translate
770 $css = "left";
771 if ($fieldlist[$field] == 'module') {
772 $valuetoshow = '&nbsp;';
773 }
774 if ($fieldlist[$field] == 'fk_user') {
775 $valuetoshow = $langs->trans("Owner");
776 }
777 if ($fieldlist[$field] == 'lang') {
778 $valuetoshow = (!getDolGlobalInt('MAIN_MULTILANGS') ? '&nbsp;' : $langs->trans("Language"));
779 }
780 if ($fieldlist[$field] == 'type') {
781 $valuetoshow = $langs->trans("Type");
782 }
783 if ($fieldlist[$field] == 'position') {
784 $css = 'center';
785 }
786 if ($fieldlist[$field] == 'code') {
787 $valuetoshow = $langs->trans("Code");
788 }
789 if ($fieldlist[$field] == 'label') {
790 $valuetoshow = $langs->trans("Code");
791 }
792 if ($fieldlist[$field] == 'type_template') {
793 $valuetoshow = $langs->trans("TypeOfTemplate");
794 $css = "center";
795 }
796 if (in_array($fieldlist[$field], array('private', 'private', 'defaultfortype'))) {
797 $css = 'center';
798 }
799
800 if ($fieldlist[$field] == 'topic') {
801 $valuetoshow = '';
802 }
803 if ($fieldlist[$field] == 'joinfiles') {
804 $valuetoshow = '';
805 }
806 if ($fieldlist[$field] == 'content') {
807 $valuetoshow = '';
808 }
809 if ($fieldlist[$field] == 'content_lines') {
810 $valuetoshow = '';
811 }
812 if ($valuetoshow != '') {
813 print '<th class="'.$css.'">';
814 if (!empty($tabhelp[25][$value]) && preg_match('/^http(s*):/i', $tabhelp[25][$value])) {
815 print '<a href="'.$tabhelp[25][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
816 } elseif (!empty($tabhelp[25][$value])) {
817 if (in_array($value, array('topic'))) {
818 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
819 } else {
820 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2); // Tooltip on hover
821 }
822 } else {
823 print $valuetoshow;
824 }
825 print '</th>';
826 }
827 }
828 print '<th>';
829 print '</th>';
830 print '</tr>';
831
832 $tmpaction = 'create';
833 $parameters = array(
834 'fieldlist' => $fieldlist,
835 'tabname' => $tabname[25]
836 );
837 $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
838 $error = $hookmanager->error;
839 $errors = $hookmanager->errors;
840
841
842 // Line to enter new values (input fields)
843 print '<tr class="oddeven">';
844
845 if (empty($reshook)) {
846 if ($action == 'edit') {
847 fieldList($fieldlist, $obj, $tabname[25], 'hide');
848 } else {
849 fieldList($fieldlist, $obj, $tabname[25], 'add');
850 }
851 }
852 // Action column
853 print '<td class="right">';
854 print '</td>';
855 print "</tr>";
856
857 print '<tr class="oddeven nodrag nodrop nohover"><td colspan="9">';
858
859 // Show fields for topic, join files and body
860 $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content');
861 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
862 $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content', 'content_lines');
863 }
864 foreach ($fieldsforcontent as $tmpfieldlist) {
865 // Topic of email
866 if ($tmpfieldlist == 'topic') {
867 print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
868 }
869 if ($tmpfieldlist == 'email_from') {
870 print $form->textwithpicto($langs->trans("MailFrom"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist);
871 }
872 if ($tmpfieldlist == 'joinfiles') {
873 print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
874 }
875 if ($tmpfieldlist == 'content') {
876 print $form->textwithpicto($langs->trans("Content"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
877 }
878 if ($tmpfieldlist == 'content_lines') {
879 print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
880 }
881
882 // Input field
883 if ($tmpfieldlist == 'topic') {
884 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
885 } elseif ($tmpfieldlist == 'email_from') {
886 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
887 } elseif ($tmpfieldlist == 'joinfiles') {
888 print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1);
889 } else {
890 $okforextended = true;
891 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
892 $okforextended = false;
893 }
894 $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : ''), '', 400, 'dolibarr_mailings', 'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
895 print $doleditor->Create(1);
896 }
897 print '<br>';
898 }
899
900 print '</tr>';
901
902 print '</table>';
903
904 if ($action != 'edit') {
905 print '<center>';
906 print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"> ';
907 print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
908 print '</center>';
909 }
910
911 print '</div>';
912 print '</form>';
913
914 print '<br><br><br>';
915}
916
917// List of available record in database
918dol_syslog("htdocs/admin/dict", LOG_DEBUG);
919$resql = $db->query($sql);
920if (!$resql) {
921 dol_print_error($db);
922 exit;
923}
924
925$num = $db->num_rows($resql);
926
927print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
928print '<input type="hidden" name="token" value="'.newToken().'">';
929print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
930
931print '<div class="div-table-responsive-no-min">';
932print '<table class="noborder centpercent">';
933
934$i = 0;
935
936$param = '';
937if ($search_label) {
938 $param .= '&search_label='.urlencode($search_label);
939}
940if (!empty($search_lang) && $search_lang != '-1') {
941 $param .= '&search_lang='.urlencode($search_lang);
942}
943if ($search_type_template != '-1') {
944 $param .= '&search_type_template='.urlencode($search_type_template);
945}
946if ($search_fk_user > 0) {
947 $param .= '&search_fk_user='.urlencode($search_fk_user);
948}
949if ($search_module) {
950 $param .= '&search_module='.urlencode($search_module);
951}
952if ($search_topic) {
953 $param .= '&search_topic='.urlencode($search_topic);
954}
955
956$paramwithsearch = $param;
957if ($sortorder) {
958 $paramwithsearch .= '&sortorder='.urlencode($sortorder);
959}
960if ($sortfield) {
961 $paramwithsearch .= '&sortfield='.urlencode($sortfield);
962}
963if (GETPOST('from', 'alpha')) {
964 $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
965}
966
967// There is several pages
968if ($num > $listlimit) {
969 print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
970 print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
971 print '</td></tr>';
972}
973
974
975// Title line with search boxes
976print '<tr class="liste_titre">';
977// Action column
978if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
979 print '<td class="liste_titre center" width="64">';
980 $searchpicto = $form->showFilterButtons();
981 print $searchpicto;
982 print '</td>';
983}
984foreach ($fieldlist as $field => $value) {
985 if ($value == 'module') {
986 print '<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).'"></td>';
987 } elseif ($value == 'label') {
988 print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).'"></td>';
989 } elseif ($value == 'lang') {
990 print '<td class="liste_titre">';
991 print $formadmin->select_language($search_lang, 'search_lang', 0, array(), 1, 0, 0, 'maxwidth100');
992 print '</td>';
993 } elseif ($value == 'fk_user') {
994 print '<td class="liste_titre">';
995 print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), array(), '0', 0, 0, '', 0, '', 'maxwidth100', 1);
996 print '</td>';
997 } elseif ($value == 'topic') {
998 print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
999 } elseif ($value == 'type_template') {
1000 print '<td class="liste_titre center">';
1001 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1002 print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth125', 1, '', 0, 1);
1003 print '</td>';
1004 } elseif (!in_array($value, array('content', 'content_lines'))) {
1005 print '<td class="liste_titre"></td>';
1006 }
1007}
1008/*if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
1009 print '<td class="liste_titre"></td>';
1010}*/
1011// Status
1012print '<td></td>';
1013// Action column
1014if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1015 print '<td class="liste_titre center" width="64">';
1016 $searchpicto = $form->showFilterButtons();
1017 print $searchpicto;
1018 print '</td>';
1019}
1020print '</tr>';
1021
1022// Title of lines
1023print '<tr class="liste_titre">';
1024// Action column
1025if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1026 print getTitleFieldOfList('');
1027}
1028foreach ($fieldlist as $field => $value) {
1029 $showfield = 1; // By default
1030 $css = "left";
1031 $sortable = 1;
1032 $valuetoshow = '';
1033 $forcenowrap = 1;
1034 /*
1035 $tmparray=getLabelOfField($fieldlist[$field]);
1036 $showfield=$tmp['showfield'];
1037 $valuetoshow=$tmp['valuetoshow'];
1038 $css=$tmp['align'];
1039 $sortable=$tmp['sortable'];
1040 */
1041 $valuetoshow = ucfirst($fieldlist[$field]); // By default
1042 $valuetoshow = $langs->trans($valuetoshow); // try to translate
1043 if ($fieldlist[$field] == 'module') {
1044 $css = 'tdoverflowmax100';
1045 }
1046 if ($fieldlist[$field] == 'fk_user') {
1047 $valuetoshow = $langs->trans("Owner");
1048 }
1049 if ($fieldlist[$field] == 'lang') {
1050 $valuetoshow = $langs->trans("Language");
1051 }
1052 if ($fieldlist[$field] == 'type') {
1053 $valuetoshow = $langs->trans("Type");
1054 }
1055 if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
1056 $valuetoshow = $langs->trans("Code");
1057 }
1058 if ($fieldlist[$field] == 'type_template') {
1059 $css = 'center';
1060 $valuetoshow = $langs->trans("TypeOfTemplate");
1061 }
1062 if ($fieldlist[$field] == 'private') {
1063 $css = 'center';
1064 }
1065 if ($fieldlist[$field] == 'position') {
1066 $css = 'center';
1067 }
1068
1069 if ($fieldlist[$field] == 'joinfiles') {
1070 $valuetoshow = $langs->trans("FilesAttachedToEmail");
1071 $css = 'center';
1072 $forcenowrap = 0;
1073 }
1074 if ($fieldlist[$field] == 'content') {
1075 $valuetoshow = $langs->trans("Content");
1076 $showfield = 0;
1077 }
1078 if ($fieldlist[$field] == 'content_lines') {
1079 $valuetoshow = $langs->trans("ContentForLines");
1080 $showfield = 0;
1081 }
1082
1083 // Show fields
1084 if ($showfield) {
1085 if (!empty($tabhelp[25][$value])) {
1086 if (in_array($value, array('topic'))) {
1087 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
1088 } else {
1089 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
1090 }
1091 }
1092 $sortfieldtouse = ($sortable ? $fieldlist[$field] : '');
1093 if ($sortfieldtouse == 'type_template') {
1094 $sortfieldtouse .= ',lang,position,label';
1095 }
1096 print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' ');
1097 }
1098}
1099
1100print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
1101// Action column
1102if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1103 print getTitleFieldOfList('');
1104}
1105print '</tr>';
1106
1107$nbqualified = 0;
1108if ($num) {
1109 // Lines with values
1110 while ($i < $num) {
1111 $obj = $db->fetch_object($resql);
1112
1113 if ($obj) {
1114 if (($action == 'edit' || $action == 'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1115 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1116
1117 $tmpaction = 'edit';
1118 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[25]);
1119 $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1120 $error = $hookmanager->error;
1121 $errors = $hookmanager->errors;
1122
1123 // Action column
1124 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1125 print '<td class="center">';
1126 print '<input type="hidden" name="page" value="'.$page.'">';
1127 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1128 if ($action == 'edit') {
1129 print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1130 }
1131 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1132 print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1133 print '</td>';
1134 }
1135 // Show main fields
1136 if (empty($reshook)) {
1137 fieldList($fieldlist, $obj, $tabname[25], $action);
1138 }
1139 // Action column
1140 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1141 print '<td class="center">';
1142 print '<input type="hidden" name="page" value="'.$page.'">';
1143 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1144 if ($action == 'edit') {
1145 print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1146 }
1147 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1148 print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1149 print '</td>';
1150 }
1151 print "</tr>\n";
1152
1153 print '<tr class="oddeven nohover" id="tr-aaa-'.$rowid.'">';
1154 print '<td colspan="10" class="paddingleft" style="padding-left: 20px">';
1155
1156 $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content');
1157 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
1158 $fieldsforcontent[] = 'content_lines';
1159 }
1160
1161 $parameters = array('fieldsforcontent' => &$fieldsforcontent, 'tabname' => $tabname[25]);
1162 $hookmanager->executeHooks('editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1163
1164 foreach ($fieldsforcontent as $tmpfieldlist) {
1165 $showfield = 1;
1166 $css = "left";
1167 $valuetoshow = $obj->$tmpfieldlist;
1168
1169 $class = 'tddict';
1170 // Show value for field
1171 if ($showfield) {
1172 // Show line for topic, joinfiles and content
1173 if ($tmpfieldlist == 'topic') {
1174 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1175 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1176 print '<br>'."\n";
1177 }
1178 if ($tmpfieldlist == 'email_from') {
1179 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1180 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1181 print '<br>'."\n";
1182 }
1183 if ($tmpfieldlist == 'joinfiles') {
1184 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1185 print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, ($action != 'edit'), 0, 1);
1186 print '<br>'."\n";
1187 }
1188
1189 if ($tmpfieldlist == 'content') {
1190 print $form->textwithpicto($langs->trans("Content"), $tabhelp[25][$tmpfieldlist], 1, 'help', 'margintoponly', 0, 2, $tmpfieldlist).'<br>';
1191 $okforextended = true;
1192 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1193 $okforextended = false;
1194 }
1195 $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%', ($action != 'edit' ? 1 : 0));
1196 print $doleditor->Create(1);
1197 }
1198 if ($tmpfieldlist == 'content_lines') {
1199 print '<br>'."\n";
1200 print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[25][$tmpfieldlist], 1, 'help', 'margintoponly', 0, 2, $tmpfieldlist).'<br>';
1201 $okforextended = true;
1202 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1203 $okforextended = false;
1204 }
1205 $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
1206 print $doleditor->Create(1);
1207 }
1208 }
1209 }
1210 print '</td>';
1211 print '<td></td>';
1212 print '<td></td>';
1213
1214 print "</tr>\n";
1215
1216 $nbqualified++;
1217 } else {
1218 // If template is for a module, check module is enabled.
1219 if ($obj->module) {
1220 $tempmodulekey = $obj->module;
1221 if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) {
1222 $i++;
1223 continue;
1224 }
1225 }
1226
1227 $keyforobj = 'type_template';
1228 if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1229 $i++;
1230 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)
1231 }
1232 // Test on 'enabled'
1233 if (! (int) dol_eval((string) $obj->enabled, 1, 1, '1')) {
1234 $i++;
1235 continue; // Email template not qualified
1236 }
1237
1238 $nbqualified++;
1239
1240 // Can an entry be erased or disabled ?
1241 $iserasable = 1;
1242 $canbedisabled = 1;
1243 $canbemodified = 1; // true by default
1244 if (!$user->admin && $obj->fk_user != $user->id) {
1245 $iserasable = 0;
1246 $canbedisabled = 0;
1247 $canbemodified = 0;
1248 }
1249
1250 $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) : '');
1251 if ($param) {
1252 $url .= '&'.$param;
1253 }
1254
1255 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1256
1257 // Action column - Modify link / Delete link
1258 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1259 print '<td class="center nowraponall" width="64">';
1260 if ($canbemodified) {
1261 print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1262 } else {
1263 print '<a class="reposition editfielda" href="'.$url.'&action=preview&token='.newToken().'">'.img_view().'</a>';
1264 }
1265 if ($iserasable) {
1266 print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().$param.'">'.img_delete().'</a>';
1267 }
1268 print '</td>';
1269 }
1270
1271 $tmpaction = 'view';
1272 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[25]);
1273 $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1274
1275 $error = $hookmanager->error;
1276 $errors = $hookmanager->errors;
1277
1278 if (empty($reshook)) {
1279 foreach ($fieldlist as $field => $value) {
1280 if (in_array($fieldlist[$field], array('content', 'content_lines'))) {
1281 continue;
1282 }
1283 $showfield = 1;
1284 $css = "";
1285 $class = "tddict";
1286 $title = '';
1287 $tmpvar = $fieldlist[$field];
1288 $valuetoshow = $obj->$tmpvar;
1289 if ($value == 'label' || $value == 'topic') {
1290 if ($langs->trans($valuetoshow) != $valuetoshow) {
1291 $valuetoshow = $langs->trans($valuetoshow);
1292 }
1293 $valuetoshow = dol_escape_htmltag($valuetoshow);
1294 }
1295 if ($value == 'label') {
1296 $class .= ' tdoverflowmax200';
1297 }
1298 if ($value == 'topic') {
1299 $class .= ' tdoverflowmax200 small';
1300 }
1301 if ($value == 'type_template') {
1302 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1303 $css = "center tdoverflowmax150";
1304 }
1305 if ($value == 'lang' && $valuetoshow) {
1306 $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
1307 $class .= ' tdoverflowmax100';
1308 }
1309 if ($value == 'fk_user') {
1310 if ($valuetoshow > 0) {
1311 $fuser = new User($db);
1312 $fuser->fetch($valuetoshow);
1313 $valuetoshow = $fuser->getNomUrl(-1);
1314 $class .= ' tdoverflowmax100';
1315 }
1316 }
1317 if ($value == 'private') {
1318 $css = "center";
1319 if ($valuetoshow) {
1320 $valuetoshow = yn($valuetoshow);
1321 } else {
1322 $valuetoshow = '';
1323 }
1324 }
1325 if ($value == 'position') {
1326 $css = "center";
1327 }
1328 if (in_array($value, array('joinfiles', 'defaultfortype'))) {
1329 $css = "center";
1330 if ($valuetoshow) {
1331 //$valuetoshow = yn(1);
1332 $valuetoshow = '<input type="checkbox" checked="checked" disabled>';
1333 } else {
1334 $valuetoshow = '';
1335 }
1336 }
1337 if ($css) {
1338 $class .= ' '.$css;
1339 }
1340
1341 // Show value for field
1342 if ($showfield) {
1343 print '<!-- '.$fieldlist[$field].' -->';
1344 print '<td class="'.$class.'"';
1345 if (in_array($value, array('code', 'label', 'topic'))) {
1346 print ' title="'.dol_escape_htmltag($valuetoshow).'"';
1347 }
1348 print '>';
1349 print $valuetoshow;
1350 print '</td>';
1351 }
1352 }
1353 }
1354
1355 // Status / Active
1356 print '<td class="center nowrap">';
1357 if ($canbedisabled) {
1358 print '<a class="reposition" href="'.$url.'&action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
1359 } else {
1360 print '<span class="opacitymedium">'.$actl[$obj->active].'</span>';
1361 }
1362 print "</td>";
1363
1364 // Action column - Modify link / Delete link
1365 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1366 print '<td class="center nowraponall" width="64">';
1367 if ($canbemodified) {
1368 print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1369 }
1370 if ($iserasable) {
1371 print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
1372 //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1373 }
1374 print '</td>';
1375 }
1376
1377 print "</tr>\n";
1378 }
1379 }
1380
1381 $i++;
1382 }
1383}
1384
1385// If no record found
1386if ($nbqualified == 0) {
1387 $colspan = 12;
1388 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1389}
1390
1391print '</table>';
1392print '</div>';
1393
1394print '</form>';
1395
1396
1397if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
1398 print dol_get_fiche_end();
1399}
1400
1401
1402// End of page
1403llxFooter();
1404$db->close();
1405
1406
1416function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
1417{
1418 global $langs, $user, $db;
1419 global $form;
1420 global $elementList;
1421
1422 $formadmin = new FormAdmin($db);
1423
1424 foreach ($fieldlist as $field => $value) {
1425 //print $value;
1426 if ($value == 'module') {
1427 print '<td></td>';
1428 } elseif ($value == 'fk_user') {
1429 print '<td>';
1430 if ($user->admin && $context != 'preview') {
1431 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');
1432 } else {
1433 if ($context == 'add') { // I am not admin and we show the add form
1434 print $user->getNomUrl(-1); // Me
1435 $forcedvalue = $user->id;
1436 } else {
1437 if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1438 $fuser = new User($db);
1439 $fuser->fetch($obj->$value);
1440 print $fuser->getNomUrl(-1);
1441 $forcedvalue = $fuser->id;
1442 } else {
1443 $forcedvalue = $obj->$value;
1444 }
1445 }
1446 $keyname = $value;
1447 print '<input type="hidden" value="'.$forcedvalue.'" name="'.$keyname.'">';
1448 }
1449 print '</td>';
1450 } elseif ($value == 'lang') {
1451 print '<td>';
1452 if (getDolGlobalInt('MAIN_MULTILANGS') && $context != 'preview') {
1453 $selectedlang = GETPOSTISSET('langcode') ? GETPOST('langcode', 'aZ09') : $langs->defaultlang;
1454 if ($context == 'edit') {
1455 $selectedlang = $obj->lang;
1456 }
1457 print $formadmin->select_language($selectedlang, 'langcode', 0, array(), 1, 0, 0, 'maxwidth100');
1458 } else {
1459 if (!empty($obj->lang)) {
1460 print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang);
1461 }
1462 $keyname = $value;
1463 if ($keyname == 'lang') {
1464 $keyname = 'langcode'; // Avoid conflict with lang param
1465 }
1466 print '<input type="hidden" value="'.(empty($obj->lang) ? '' : $obj->lang).'" name="'.$keyname.'">';
1467 }
1468 print '</td>';
1469 } elseif ($value == 'type_template') {
1470 // Le type de template
1471 print '<td class="center">';
1472 if (($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) || $context == 'preview') {
1473 // Current template type is an unknown type, so we must keep it as it is.
1474 print '<input type="hidden" name="type_template" value="'.$obj->type_template.'">';
1475 print $obj->type_template;
1476 } else {
1477 print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template : ''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1);
1478 }
1479 print '</td>';
1480 } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1481 //print '<td></td>';
1482 } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1483 print '<td></td>';
1484 } elseif ($context == 'preview' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1485 print '<td></td>';
1486 } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1487 //print '<td></td>';
1488 } else {
1489 $size = '';
1490 $class = '';
1491 $classtd = '';
1492 if ($value == 'code') {
1493 $class = 'maxwidth100';
1494 }
1495 if ($value == 'label') {
1496 $class = 'maxwidth200';
1497 }
1498 if ($value == 'private') {
1499 $class = 'maxwidth50';
1500 $classtd = 'center';
1501 }
1502 if ($value == 'position') {
1503 $class = 'maxwidth50 center';
1504 $classtd = 'center';
1505 }
1506 if ($value == 'topic') {
1507 $class = 'quatrevingtpercent';
1508 }
1509 if ($value == 'defaultfortype') {
1510 $class = 'width25 center';
1511 $classtd = 'center';
1512 }
1513
1514 print '<td'.($classtd ? ' class="'.$classtd.'"' : '').'>';
1515 if ($value == 'private' && $context != 'preview') {
1516 if (empty($user->admin)) {
1517 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1518 print $form->selectyesno($value, GETPOSTISSET($value) ? GETPOSTINT($value) : (($context != 'add' && isset($obj->$value)) ? $obj->$value : '1'), 1, false, 0, 1);
1519 } else {
1520 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1521 print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1, false, 0, 1);
1522 }
1523 } else {
1524 print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'"'.($context == 'preview' ? ' disabled' : '').'>';
1525 }
1526 print '</td>';
1527 }
1528 }
1529}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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:91
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:73
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, $morecssdiv='')
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.