40require
'../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/cemailtemplate.class.php';
58$langsArray = array(
"errors",
"admin",
"mails",
"languages");
61 $langsArray[] =
'members';
64 $langsArray[] =
'eventorganization';
67$langs->loadLangs($langsArray);
69$toselect =
GETPOST(
'toselect',
'array:int');
70$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
71$massaction =
GETPOST(
'massaction',
'alpha');
72$confirm =
GETPOST(
'confirm',
'alpha');
74$optioncss =
GETPOST(
'optioncss',
'alpha');
75$backtopage =
GETPOST(
'backtopage');
76$contextpage =
GETPOST(
'contextpage',
'aZ09');
79$search_label =
GETPOST(
'search_label',
'alphanohtml');
80$search_type_template =
GETPOST(
'search_type_template',
'alpha');
81$search_lang =
GETPOST(
'search_lang',
'alpha');
82$search_fk_user =
GETPOST(
'search_fk_user',
'intcomma');
83$search_topic =
GETPOST(
'search_topic',
'alpha');
84$search_module =
GETPOST(
'search_module',
'alpha');
90$actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
91$actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
93$listoffset =
GETPOST(
'listoffset',
'alpha');
94$listlimit =
GETPOST(
'listlimit',
'alpha') > 0 ?
GETPOST(
'listlimit',
'alpha') : 1000;
97$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
98$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
100if (empty($page) || $page == -1) {
103$offset = $listlimit * $page;
104$pageprev = $page - 1;
105$pagenext = $page + 1;
107if (empty($sortfield)) {
108 $sortfield =
'type_template,lang,position,label';
110if (empty($sortorder)) {
115$hookmanager->initHooks(array(
'emailtemplates'));
121$arrayfields = array();
122foreach (
$object->fields as $key => $val) {
124 if (!empty($val[
'visible'])) {
125 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
126 $arrayfields[$tableprefix.
'.'.$key] = array(
127 'label' => $val[
'label'],
128 'checked' => (($visible < 0) ?
'0' :
'1'),
129 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
130 'position' => $val[
'position'],
131 'help' => isset($val[
'help']) ? $val[
'help'] :
''
140$tabname[25] = MAIN_DB_PREFIX.
"c_email_templates";
145$tabfield[25] =
"label,lang,type_template,fk_user,position,module,topic,joinfiles,defaultfortype,content";
147 $tabfield[25] .=
',content_lines';
152$tabfieldvalue = array();
153$tabfieldvalue[25] =
"label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
155 $tabfieldvalue[25] .=
',content_lines';
160$tabfieldinsert = array();
161$tabfieldinsert[25] =
"label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content,datec";
163 $tabfieldinsert[25] .=
',content_lines';
165$tabfieldinsert[25] .=
',entity';
169require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
173 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
174 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
175 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
176 foreach ($tmp as $key => $val) {
177 $helpsubstit .= $key.
' -> '.$val.
'<br>';
178 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
182 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
183 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
184 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
185 foreach ($tmp as $key => $val) {
186 $helpsubstit .= $key.
' -> '.$val.
'<br>';
189 foreach ($tmp as $key => $val) {
190 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
197 'label' => $langs->trans(
'EnterAnyCode'),
198 'type_template' => $langs->trans(
"TemplateForElement"),
199 'private' => $langs->trans(
"TemplateIsVisibleByOwnerOnly"),
200 'position' => $langs->trans(
"PositionIntoComboList"),
201 'topic' =>
'<span class="small">'.$helpsubstit.
'</span>',
202 'email_from' => $langs->trans(
'ForceEmailFrom'),
203 'joinfiles' => $langs->trans(
'AttachMainDocByDefault'),
204 'defaultfortype' => $langs->trans(
"DefaultForTypeDesc"),
205 'content' =>
'<span class="small">'.$helpsubstit.
'</span>',
206 'content_lines' =>
'<span class="small">'.$helpsubstitforlines.
'</span>'
211$elementList = array();
214$elementList[
'all'] =
'-- '.dol_escape_htmltag($langs->trans(
"All")).
' --';
215$elementList[
'none'] =
'-- '.dol_escape_htmltag($langs->trans(
"None")).
' --';
216$elementList[
'user'] =
img_picto(
'',
'user',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToUser'));
217if (
isModEnabled(
'member') && $user->hasRight(
'adherent',
'lire')) {
218 $elementList[
'member'] =
img_picto(
'',
'object_member',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToMember'));
220if (
isModEnabled(
'recruitment') && $user->hasRight(
'recruitment',
'recruitmentjobposition',
'read')) {
221 $elementList[
'recruitmentcandidature_send'] =
img_picto(
'',
'recruitmentcandidature',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'RecruitmentCandidatures'));
223if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'lire')) {
224 $elementList[
'thirdparty'] =
img_picto(
'',
'company',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToThirdparty'));
226if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'contact',
'lire')) {
227 $elementList[
'contact'] =
img_picto(
'',
'contact',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToContact'));
230 $elementList[
'project'] =
img_picto(
'',
'project',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToProject'));
232if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
233 $elementList[
'propal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendProposal'));
235if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
236 $elementList[
'order_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendOrder'));
238if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
239 $elementList[
'facture_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendInvoice'));
242 $elementList[
'shipping_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendShipment'));
243 $elementList[
'delivery_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendDelivery'));
246 $elementList[
'reception_send'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendReception'));
249 $elementList[
'fichinter_send'] =
img_picto(
'',
'intervention',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendIntervention'));
252 $elementList[
'supplier_proposal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierRequestForQuotation'));
254if (
isModEnabled(
"supplier_order") && ($user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'read'))) {
255 $elementList[
'order_supplier_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierOrder'));
257if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
258 $elementList[
'invoice_supplier_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierInvoice'));
260if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"write"))) {
261 $elementList[
'supplier_payment_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'SuppliersPayment'));
263if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
264 $elementList[
'contract'] =
img_picto(
'',
'contract',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendContract'));
266if (
isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
267 $elementList[
'ticket_send'] =
img_picto(
'',
'ticket',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToTicket'));
269if (
isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')) {
270 $elementList[
'expensereport_send'] =
img_picto(
'',
'trip',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToExpenseReport'));
273 $elementList[
'actioncomm_send'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventPush'));
275if (
isModEnabled(
'eventorganization') && $user->hasRight(
'project',
'read')) {
276 $elementList[
'conferenceorbooth'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventOrganization'));
278if (
isModEnabled(
'partnership') && $user->hasRight(
'partnership',
'read')) {
279 $elementList[
'partnership_send'] =
img_picto(
'',
'partnership',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToPartnership'));
281if (
isModEnabled(
'product') && $user->hasRight(
'produit',
'lire')) {
282 $elementList[
'product_send'] =
img_picto(
'',
'product',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'Product'));
285$parameters = array(
'elementList' => $elementList);
286$reshook = $hookmanager->executeHooks(
'emailElementlist', $parameters);
288 foreach ($hookmanager->resArray as $item => $value) {
289 $elementList[$item] = $value;
298if (!empty($user->socid)) {
303$permissiontoedit = ($user->admin ? 1 : 0);
304$permissiontodelete = ($user->admin ? 1 : 0);
307 $tmpmailtemplate->fetch($rowid);
308 if ($tmpmailtemplate->fk_user == $user->id) {
309 $permissiontoedit = 1;
310 $permissiontodelete = 1;
319if (
GETPOST(
'cancel',
'alpha') ||
GETPOST(
'actioncancel',
'alpha')) {
323 if (!empty($backtopage)) {
324 header(
"Location: ".$backtopage);
328if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
332$parameters = array();
334$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
339if (empty($reshook)) {
341 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
344 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
347 $search_type_template =
'';
349 $search_fk_user =
'';
353 $search_array_options = array();
357 if ((
GETPOST(
'actionadd',
'alpha') && $permissiontoadd) || (
GETPOST(
'actionmodify',
'alpha') && $permissiontoedit)) {
358 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[25]));
359 $listfieldinsert = explode(
',', $tabfieldinsert[25]);
360 $listfieldmodify = explode(
',', $tabfieldvalue[25]);
361 $listfieldvalue = explode(
',', $tabfieldvalue[25]);
365 foreach ($listfield as $f => $value) {
367 if (in_array($value, [
'joinfiles',
'defaultfortype',
'content',
'content_lines',
'module',
'tms',
'datec'])) {
372 if (
GETPOST(
'actionmodify',
'alpha') && $value ==
'topic') {
373 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
376 if ((!GETPOSTISSET($value) ||
GETPOST($value) ==
'' ||
GETPOST($value) ==
'-1') && $value !=
'lang' && $value !=
'fk_user' && $value !=
'position') {
378 $fieldnamekey = $listfield[$f];
380 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
381 $fieldnamekey =
'Code';
383 if ($fieldnamekey ==
'code') {
384 $fieldnamekey =
'Code';
386 if ($fieldnamekey ==
'note') {
387 $fieldnamekey =
'Note';
389 if ($fieldnamekey ==
'type_template') {
390 $fieldnamekey =
'TypeOfTemplate';
392 if ($fieldnamekey ==
'fk_user') {
393 $fieldnamekey =
'Owner';
395 if ($fieldnamekey ==
'private') {
396 $fieldnamekey =
'Private';
398 if ($fieldnamekey ==
'position') {
399 $fieldnamekey =
'Position';
401 if ($fieldnamekey ==
'topic') {
402 $fieldnamekey =
'Topic';
405 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
411 if ($ok &&
GETPOST(
'actionadd')) {
413 $sql =
"INSERT INTO ".$tabname[25].
" (";
415 $sql .= $tabfieldinsert[25];
416 $sql .=
", active, enabled)";
422 foreach ($listfieldinsert as $f => $value) {
423 $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] :
"";
424 if ($value ==
'lang') {
425 $keycode =
'langcode';
427 if (empty($keycode)) {
432 if ($value ==
'entity') {
433 $_POST[$keycode] = $conf->entity;
435 if ($value ==
'fk_user' && !($_POST[$keycode] > 0)) {
436 $_POST[$keycode] =
'';
438 if ($value ==
'private' && !is_numeric($_POST[$keycode])) {
439 $_POST[$keycode] =
'0';
441 if ($value ==
'position' && !is_numeric($_POST[$keycode])) {
442 $_POST[$keycode] =
'1';
444 if ($value ==
'defaultfortype' && !is_numeric($_POST[$keycode])) {
445 $_POST[$keycode] =
'0';
452 if ($keycode ==
'datec') {
453 $sql .=
"'".$db->idate($now).
"'";
454 } elseif (
GETPOST($keycode) ==
'' && $keycode !=
'langcode') {
456 } elseif (
GETPOST($keycode) ==
'0' && $keycode ==
'langcode') {
458 } elseif ($keycode ==
'fk_user') {
460 $sql .=
" ".((int) $user->id);
462 $sql .=
" ".(GETPOSTINT($keycode));
464 } elseif ($keycode ==
'content') {
465 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
466 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private',
'position',
'entity'))) {
469 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
476 $result = $db->query($sql);
479 $_POST = array(
'id' => 25);
481 if (!empty($backtopage)) {
482 header(
"Location: ".$backtopage);
486 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
487 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
496 if ($ok &&
GETPOST(
'actionmodify')) {
500 setEventMessages($langs->trans(
"AnOwnerMustBeSetIfEmailTemplateIsPrivate"),
null,
'errors');
507 $sql =
"UPDATE ".$tabname[25].
" SET ";
510 foreach ($listfieldmodify as $field) {
511 if ($field ==
'entity') {
514 $_POST[$keycode] = $conf->entity;
516 $keycode = $listfieldvalue[$i];
519 if ($field ==
'lang') {
520 $keycode =
'langcode';
522 if (empty($keycode)) {
527 if ($field ==
'topic') {
528 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
530 if ($field ==
'joinfiles') {
531 $_POST[
'joinfiles'] =
GETPOST(
'joinfiles-'.$rowid);
533 if ($field ==
'content') {
534 $_POST[
'content'] =
GETPOST(
'content-'.$rowid,
'restricthtml');
536 if ($field ==
'content_lines') {
537 $_POST[
'content_lines'] =
GETPOST(
'content_lines-'.$rowid,
'restricthtml');
539 if ($field ==
'email_from') {
540 $_POST[
'email_from'] =
GETPOST(
'email_from-'.$rowid,
'restricthtml');
546 $sql .= $field.
" = ";
548 if ((
GETPOST($keycode) ==
'' && in_array($keycode, array(
'langcode'))) || (!in_array($keycode, array(
'langcode',
'position',
'private',
'defaultfortype')) && !
GETPOST($keycode))) {
550 } elseif ($keycode ==
'langcode' && (
GETPOST($keycode) ==
'0' ||
GETPOST($keycode) ==
'-1')) {
552 } elseif ($keycode ==
'fk_user') {
554 $sql .= ((int) $user->id);
558 } elseif ($keycode ==
'content') {
559 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
560 } elseif ($keycode ==
'position') {
562 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private'))) {
565 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
570 $sql .=
" WHERE ".$db->escape($rowidcol).
" = ".((int) $rowid);
572 $sql .=
" AND fk_user = ".((int) $user->id);
578 $resql = $db->query($sql);
592 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
595 $sql =
"DELETE from ".$tabname[25].
" WHERE ".$rowidcol.
" = ".((int) $rowid);
597 $sql .=
" AND fk_user = ".((int) $user->id);
600 $result = $db->query($sql);
602 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
603 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
611 if ($action == $acts[0] && $permissiontoedit) {
614 $sql =
"UPDATE ".$tabname[25].
" SET active = 1 WHERE rowid = ".((int) $rowid);
616 $result = $db->query($sql);
623 if ($action == $acts[1] && $permissiontoedit) {
626 $sql =
"UPDATE ".$tabname[25].
" SET active = 0 WHERE rowid = ".((int) $rowid);
628 $result = $db->query($sql);
640$form =
new Form($db);
647if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
648 $title = $langs->trans(
"EMailsSetup");
650 $title = $langs->trans(
"EMailTemplates");
655$sql =
"SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from, joinfiles, defaultfortype,";
656$sql .=
" content_lines, content, enabled, active, tms, datec";
657$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_email_templates";
658$sql .=
" WHERE entity IN (".getEntity(
'email_template').
")";
660 $sql .=
" AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id).
"))";
661 $sql .=
" AND (active = 1 OR fk_user = ".((int) $user->id).
")";
664 $sql .=
" AND (lang = '".$db->escape($langs->defaultlang).
"' OR lang IS NULL OR lang = '')";
669if ($search_type_template !=
'' && $search_type_template !=
'-1') {
675if ($search_fk_user !=
'' && $search_fk_user !=
'-1') {
685if ($sortfield ==
'country') {
686 $sortfield =
'country_code';
688$sql .= $db->order($sortfield, $sortorder);
689$sql .= $db->plimit($listlimit + 1, $offset);
695llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-admin page-mails_templates');
697$arrayofselected = is_array($toselect) ? $toselect : array();
701 $param .=
'&mode='.urlencode($mode);
703if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
704 $param .=
'&contextpage='.urlencode($contextpage);
706if ($limit > 0 && $limit != $conf->liste_limit) {
707 $param .=
'&limit='.((int) $limit);
709if (!empty($search) && is_array($search)) {
710 foreach ($search as $key => $val) {
711 if (is_array($search[$key]) && count($search[$key])) {
712 foreach ($search[$key] as $skey) {
714 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
717 } elseif ($search[$key] !=
'') {
718 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
722if ($optioncss !=
'') {
723 $param .=
'&optioncss='.urlencode($optioncss);
726include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
728$parameters = array();
729$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
730$param .= $hookmanager->resPrint;
733$titlepicto =
'title_setup';
736$url = DOL_URL_ROOT.
'/admin/mails_templates.php?action=create';
738$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewEMailTemplate'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
741if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
747if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
752 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
759if ($action ==
'delete') {
760 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);
764$fieldlist = explode(
',', $tabfield[25]);
766if ($action ==
'create') {
769 $obj->label =
GETPOST(
'label');
771 $obj->type_template =
GETPOST(
'type_template');
774 $obj->position =
GETPOST(
'position');
775 $obj->topic =
GETPOST(
'topic');
776 $obj->joinfiles =
GETPOST(
'joinfiles');
777 $obj->defaultfortype =
GETPOST(
'defaultfortype') ? 1 : 0;
778 $obj->content =
GETPOST(
'content',
'restricthtml');
781 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="create_c_email_template">';
782 print
'<input type="hidden" name="token" value="'.newToken().
'">';
783 print
'<input type="hidden" name="action" value="add">';
784 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
785 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
787 print
'<div class="div-table-responsive-no-min">';
788 print
'<table class="noborder centpercent" id="table_create_c_email_template">';
791 print
'<tr class="liste_titre">';
792 foreach ($fieldlist as $field => $value) {
795 $valuetoshow = ucfirst($fieldlist[$field]);
796 $valuetoshow = $langs->trans($valuetoshow);
798 if ($fieldlist[$field] ==
'module') {
799 $valuetoshow =
' ';
801 if ($fieldlist[$field] ==
'fk_user') {
802 $valuetoshow = $langs->trans(
"Owner");
804 if ($fieldlist[$field] ==
'lang') {
805 $valuetoshow = (!
getDolGlobalInt(
'MAIN_MULTILANGS') ?
' ' : $langs->trans(
"Language"));
807 if ($fieldlist[$field] ==
'type') {
808 $valuetoshow = $langs->trans(
"Type");
810 if ($fieldlist[$field] ==
'position') {
813 if ($fieldlist[$field] ==
'code') {
814 $valuetoshow = $langs->trans(
"Code");
816 if ($fieldlist[$field] ==
'label') {
817 $valuetoshow = $langs->trans(
"Label");
819 if ($fieldlist[$field] ==
'type_template') {
820 $valuetoshow = $langs->trans(
"TypeOfTemplate");
823 if (in_array($fieldlist[$field], array(
'private',
'private',
'defaultfortype'))) {
827 if ($fieldlist[$field] ==
'topic') {
830 if ($fieldlist[$field] ==
'joinfiles') {
833 if ($fieldlist[$field] ==
'content') {
836 if ($fieldlist[$field] ==
'content_lines') {
839 if ($valuetoshow !=
'') {
840 print
'<th class="'.$css.
'">';
841 if (!empty($tabhelp[25][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[25][$value])) {
842 print
'<a href="'.$tabhelp[25][$value].
'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
843 } elseif (!empty($tabhelp[25][$value])) {
844 if (in_array($value, array(
'topic'))) {
845 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2, $value);
847 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2);
859 $tmpaction =
'create';
861 'fieldlist' => $fieldlist,
862 'tabname' => $tabname[25]
864 $reshook = $hookmanager->executeHooks(
'createEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
865 $error = $hookmanager->error;
866 $errors = $hookmanager->errors;
870 print
'<tr class="oddeven">';
872 if (empty($reshook)) {
873 if ($action ==
'edit') {
874 fieldList($fieldlist, $obj, $tabname[25],
'hide');
876 fieldList($fieldlist, $obj, $tabname[25],
'add');
880 print
'<td class="right">';
884 print
'<tr class="oddeven nodrag nodrop nohover"><td colspan="9" style="padding-left: 20px; padding-right: 20px;">';
887 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
889 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content',
'content_lines');
891 foreach ($fieldsforcontent as $tmpfieldlist) {
892 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
894 if ($tmpfieldlist ==
'topic') {
895 print
'<span class="bold minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
897 if ($tmpfieldlist ==
'email_from') {
898 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
900 if ($tmpfieldlist ==
'joinfiles') {
901 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
903 if ($tmpfieldlist ==
'content') {
904 print
'<span class="minwidth150 inline-block margintoponly">'.$form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
906 if ($tmpfieldlist ==
'content_lines') {
907 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
911 if ($tmpfieldlist ==
'topic') {
912 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'">';
913 } elseif ($tmpfieldlist ==
'email_from') {
914 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
915 } elseif ($tmpfieldlist ==
'joinfiles') {
916 print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, false, 0, 1);
918 $okforextended =
true;
920 $okforextended =
false;
922 $doleditor =
new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
''),
'', 400,
'dolibarr_mailings',
'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'90%');
923 print $doleditor->Create(1);
933 if ($action !=
'edit') {
935 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'"> ';
936 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
943 print
'<br><br><br>';
948$resql = $db->query($sql);
954$num = $db->num_rows($resql);
956print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="list_of_c_email_templates">';
957print
'<input type="hidden" name="token" value="'.newToken().
'">';
958print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
960print
'<div class="div-table-responsive-no-min">';
961print
'<table class="noborder centpercent" id="table_list_of_c_email_templates">';
967 $param .=
'&search_label='.urlencode($search_label);
969if (!empty($search_lang) && $search_lang !=
'-1') {
970 $param .=
'&search_lang='.urlencode($search_lang);
972if ($search_type_template !=
'-1') {
973 $param .=
'&search_type_template='.urlencode($search_type_template);
975if ($search_fk_user > 0) {
976 $param .=
'&search_fk_user='.urlencode($search_fk_user);
979 $param .=
'&search_module='.urlencode($search_module);
982 $param .=
'&search_topic='.urlencode($search_topic);
985$paramwithsearch = $param;
987 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
990 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
993 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
997if ($num > $listlimit) {
998 print
'<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).
'">';
999 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
1005print
'<tr class="liste_titre" id="Title line with search boxes">';
1008 print
'<td class="liste_titre center" width="64">';
1009 $searchpicto = $form->showFilterButtons();
1013foreach ($fieldlist as $field => $value) {
1014 if ($value ==
'module') {
1015 print
'<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).
'" spellcheck="false"></td>';
1016 } elseif ($value ==
'label') {
1017 print
'<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).
'" spellcheck="false"></td>';
1018 } elseif ($value ==
'lang') {
1019 print
'<td class="liste_titre">';
1020 print $formadmin->select_language($search_lang,
'search_lang', 0, array(), 1, 0, 0,
'maxwidth100');
1022 } elseif ($value ==
'fk_user') {
1023 print
'<td class="liste_titre">';
1024 print $form->select_dolusers($search_fk_user,
'search_fk_user', 1,
null, 0, ($user->admin ?
'' :
'hierarchyme'), array(),
'0', 0, 0,
'', 0,
'',
'maxwidth100', 1);
1026 } elseif ($value ==
'topic') {
1027 print
'<td class="liste_titre"><input type="text" class="maxwidth150" name="search_topic" value="'.dol_escape_htmltag($search_topic).
'" spellcheck="false"></td>';
1028 } elseif ($value ==
'type_template') {
1029 print
'<td class="liste_titre center">';
1031 print $form->selectarray(
'search_type_template', $elementList, $search_type_template, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125', 1,
'', 0, 1);
1033 } elseif (!in_array($value, array(
'content',
'content_lines'))) {
1034 print
'<td class="liste_titre"></td>';
1044if (!empty($arrayfields[
't.tms'][
'checked'])) {
1047if (!empty($arrayfields[
't.datec'][
'checked'])) {
1052 print
'<td class="liste_titre center" width="64">';
1053 $searchpicto = $form->showFilterButtons();
1060print
'<tr class="liste_titre" id="Title of lines">';
1065array_push($fieldlist,
"tms",
"datec");
1066foreach ($fieldlist as $field => $value) {
1079 $valuetoshow = ucfirst($fieldlist[$field]);
1080 $valuetoshow = $langs->trans($valuetoshow);
1081 if ($fieldlist[$field] ==
'module') {
1082 $css =
'tdoverflowmax100';
1084 if ($fieldlist[$field] ==
'fk_user') {
1085 $valuetoshow = $langs->trans(
"Owner");
1087 if ($fieldlist[$field] ==
'lang') {
1088 $valuetoshow = $langs->trans(
"Language");
1090 if ($fieldlist[$field] ==
'type') {
1091 $valuetoshow = $langs->trans(
"Type");
1093 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
1094 $valuetoshow = $langs->trans(
"Label");
1096 if ($fieldlist[$field] ==
'type_template') {
1098 $valuetoshow = $langs->trans(
"TypeOfTemplate");
1100 if ($fieldlist[$field] ==
'private') {
1103 if ($fieldlist[$field] ==
'position') {
1106 if ($fieldlist[$field] ==
'tms') {
1107 $valuetoshow =
'Modif. date';
1109 if ($fieldlist[$field] ==
'datec') {
1110 $valuetoshow =
'Date creation';
1113 if ($fieldlist[$field] ==
'joinfiles') {
1114 $valuetoshow = $langs->trans(
"FilesAttachedToEmail");
1118 if ($fieldlist[$field] ==
'content') {
1119 $valuetoshow = $langs->trans(
"Content");
1122 if ($fieldlist[$field] ==
'content_lines') {
1123 $valuetoshow = $langs->trans(
"ContentForLines");
1126 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1129 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1135 if (!empty($tabhelp[25][$value])) {
1136 if (in_array($value, array(
'topic'))) {
1137 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'tooltip'.$value, $forcenowrap);
1139 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'', $forcenowrap);
1142 $sortfieldtouse = ($sortable ? $fieldlist[$field] :
'');
1143 if ($sortfieldtouse ==
'type_template') {
1144 $sortfieldtouse .=
',lang,position,label';
1146 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], $sortfieldtouse, ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder, $css.
' ');
1150print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
1161 $obj = $db->fetch_object($resql);
1164 if (($action ==
'edit' || $action ==
'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1166 print
'<tr class="nohover oddeven noborderbottom" id="rowid-'.$obj->rowid.
'" name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'">';
1168 $tmpaction =
'edit';
1169 if ($action ==
'edit') {
1171 $fieldlist = explode(
',', $tabfield[25]);
1172 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1174 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1176 $reshook = $hookmanager->executeHooks(
'editEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1177 $error = $hookmanager->error;
1178 $errors = $hookmanager->errors;
1184 print
'<td class="center">';
1189 if (empty($reshook)) {
1190 $colspan +=
fieldList($fieldlist, $obj, $tabname[25], $action);
1194 print
'<td class="center">';
1200 print
'<tr class="oddeven nohover" id="tr-aaa-'.$rowid.
'">';
1202 print
'<td class="center"></td>';
1204 print
'<td colspan="'.($colspan - 1).
'" class="" style="padding-left: 20px; padding-right: 20px;">';
1206 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
1208 $fieldsforcontent[] =
'content_lines';
1211 $parameters = array(
'fieldsforcontent' => &$fieldsforcontent,
'tabname' => $tabname[25]);
1212 $hookmanager->executeHooks(
'editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction);
1214 print
'<div class="lineformailtemplatefield centpercent">';
1215 foreach ($fieldsforcontent as $tmpfieldlist) {
1218 $valuetoshow = $obj->$tmpfieldlist;
1223 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
1225 if ($tmpfieldlist ==
'topic') {
1226 print
'<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1227 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
'>';
1230 if ($tmpfieldlist ==
'email_from') {
1231 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1232 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1235 if ($tmpfieldlist ==
'joinfiles') {
1236 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1237 print $form->selectyesno($tmpfieldlist.
'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, ($action !=
'edit'), 0, 1);
1241 if ($tmpfieldlist ==
'content') {
1242 print $form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1243 $okforextended =
true;
1245 $okforextended =
false;
1247 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 450,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%', ($action !=
'edit' ? 1 : 0));
1248 print $doleditor->Create(1);
1250 if ($tmpfieldlist ==
'content_lines') {
1252 print $form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1253 $okforextended =
true;
1255 $okforextended =
false;
1257 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 140,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%');
1258 print $doleditor->Create(1);
1264 print
'<center><input type="hidden" name="page" value="'.$page.
'">';
1265 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
1266 if ($action ==
'edit') {
1267 print
'<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans(
"Save").
'">';
1269 print
'<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
1274 print
'<td class="center"></td>';
1283 $tempmodulekey = $obj->module;
1284 if (empty($conf->$tempmodulekey) || !
isModEnabled($tempmodulekey)) {
1290 $keyforobj =
'type_template';
1291 if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1296 if (! (
int)
dol_eval((
string) $obj->enabled, 1, 1,
'1')) {
1307 if (!$user->admin && $obj->fk_user != $user->id) {
1313 $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) :
'');
1318 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
1322 print
'<td class="center nowraponall" width="64">';
1323 if ($canbemodified) {
1324 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
1326 print
'<a class="reposition editfielda" href="'.$url.
'&action=preview&token='.
newToken().
'">'.
img_view().
'</a>';
1329 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.
newToken().$param.
'">'.
img_delete().
'</a>';
1334 $tmpaction =
'view';
1335 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1336 $reshook = $hookmanager->executeHooks(
'viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1338 $error = $hookmanager->error;
1339 $errors = $hookmanager->errors;
1341 if (empty($reshook)) {
1342 foreach ($fieldlist as $field => $value) {
1343 if (in_array($fieldlist[$field], array(
'content',
'content_lines'))) {
1350 $tmpvar = $fieldlist[$field];
1351 $valuetoshow = $obj->$tmpvar;
1352 if ($value ==
'label' || $value ==
'topic') {
1353 if ($langs->trans($valuetoshow) != $valuetoshow) {
1354 $valuetoshow = $langs->trans($valuetoshow);
1358 if ($value ==
'label') {
1359 $class .=
' tdoverflowmax200';
1361 if ($value ==
'topic') {
1362 $class .=
' tdoverflowmax200 small';
1364 if ($value ==
'type_template') {
1365 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1366 $css =
"center tdoverflowmax150";
1368 if ($value ==
'lang' && $valuetoshow) {
1369 $valuetoshow = $valuetoshow.
' - '.$langs->trans(
"Language_".$valuetoshow);
1370 $class .=
' tdoverflowmax100';
1372 if ($value ==
'fk_user') {
1373 if ($valuetoshow > 0) {
1374 $fuser =
new User($db);
1375 $fuser->fetch($valuetoshow);
1376 $valuetoshow = $fuser->getNomUrl(-1);
1378 if ($obj->private) {
1379 $valuetoshow =
img_picto($langs->transnoentitiesnoconv(
"Private"),
'lock',
'class="pictofixedwidth"').$valuetoshow;
1382 $class .=
' tdoverflowmax100';
1385 if ($value ==
'private') {
1388 $valuetoshow =
yn($valuetoshow);
1393 if ($value ==
'position') {
1396 if (in_array($value, array(
'joinfiles',
'defaultfortype'))) {
1400 $valuetoshow =
'<input type="checkbox" checked="checked" disabled>';
1409 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1412 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1418 print
'<!-- '.$fieldlist[$field].
' -->';
1419 print
'<td class="'.$class.
'"';
1420 if (in_array($value, array(
'code',
'label',
'topic'))) {
1421 print
' title="'.dol_escape_htmltag($valuetoshow).
'"';
1431 print
'<td class="center nowrap">';
1432 if ($canbedisabled) {
1433 print
'<a class="reposition" href="'.$url.
'&action='.$acts[$obj->active].
'&token='.
newToken().
'">'.$actl[$obj->active].
'</a>';
1435 print
'<span class="opacitymedium">'.$actl[$obj->active].
'</span>';
1441 print
'<td class="center nowraponall" width="64">';
1442 if ($canbemodified) {
1443 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
1446 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
1461if ($nbqualified == 0) {
1463 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1472if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
1493 global $langs, $user, $db;
1495 global $elementList;
1498 $nboffieldsprinted = 0;
1500 foreach ($fieldlist as $value) {
1502 if ($value ==
'module') {
1504 $nboffieldsprinted++;
1505 } elseif ($value ==
'fk_user') {
1507 if ($user->admin &&
$context !=
'preview') {
1508 print $form->select_dolusers(GETPOSTISSET(
'fk_user') ?
GETPOSTINT(
'fk_user') : (empty($obj->$value) ?
'' : $obj->$value),
'fk_user', $langs->trans(
"Owner"), array(), 0, ($user->admin ?
'' :
'hierarchyme'), array(),
'0', 0, 0,
'', 0,
'',
'minwidth75 maxwidth100');
1511 print $user->getNomUrl(-1);
1512 $forcedvalue = $user->id;
1514 if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1515 $fuser =
new User($db);
1516 $fuser->fetch($obj->$value);
1517 print $fuser->getNomUrl(-1);
1518 $forcedvalue = $fuser->id;
1520 $forcedvalue = $obj->$value;
1524 print
'<input type="hidden" value="'.$forcedvalue.
'" name="'.$keyname.
'">';
1527 $nboffieldsprinted++;
1528 } elseif ($value ==
'lang') {
1531 $selectedlang = GETPOSTISSET(
'langcode') ?
GETPOST(
'langcode',
'aZ09') : $langs->defaultlang;
1533 $selectedlang = $obj->lang;
1535 print $formadmin->select_language($selectedlang,
'langcode', 0, array(), $langs->trans(
"Language"), 0, 0,
'maxwidth100');
1537 if (!empty($obj->lang)) {
1538 print $obj->lang.
' - '.$langs->trans(
'Language_'.$obj->lang);
1541 if ($keyname ==
'lang') {
1542 $keyname =
'langcode';
1544 print
'<input type="hidden" value="'.(empty($obj->lang) ?
'' : $obj->lang).
'" name="'.$keyname.
'">';
1547 $nboffieldsprinted++;
1548 } elseif ($value ==
'type_template') {
1550 print
'<td class="center">';
1551 if ((
$context ==
'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) ||
$context ==
'preview') {
1553 print
'<input type="hidden" name="type_template" value="'.$obj->type_template.
'">';
1554 print $obj->type_template;
1556 print $form->selectarray(
'type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 maxwidth125', 1,
'', 0, 1);
1559 $nboffieldsprinted++;
1560 } elseif (
$context ==
'add' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1562 } elseif (
$context ==
'edit' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1564 $nboffieldsprinted++;
1565 } elseif (
$context ==
'preview' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1567 $nboffieldsprinted++;
1568 } elseif (
$context ==
'hide' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1574 if ($value ==
'code') {
1575 $class =
'maxwidth100';
1577 if ($value ==
'label') {
1578 $class =
'maxwidth200';
1580 if ($value ==
'private') {
1581 $class =
'maxwidth50';
1582 $classtd =
'center';
1584 if ($value ==
'position') {
1585 $class =
'maxwidth50 center';
1586 $classtd =
'center';
1588 if ($value ==
'topic') {
1589 $class =
'quatrevingtpercent';
1591 if ($value ==
'defaultfortype') {
1592 $class =
'width25 center';
1593 $classtd =
'center';
1596 print
'<td'.($classtd ?
' class="'.$classtd.
'"' :
'').
'>';
1597 if (in_array($value, array(
'defaultfortype',
'private')) &&
$context !=
'preview') {
1598 if (empty($user->admin)) {
1600 print $form->selectyesno($value, GETPOSTISSET($value) ?
GETPOSTINT($value) : ((
$context !=
'add' && isset($obj->$value)) ? $obj->$value :
'1'), 1,
false, 0, 1);
1603 print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value :
''), 1,
false, 0, 1);
1606 print
'<input type="text" '.$size.
'class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->$value) ? $obj->$value :
'').
'" name="'. $value .
'"'.(
$context ==
'preview' ?
' disabled' :
'').
' spellcheck="false">';
1609 $nboffieldsprinted++;
1613 return $nboffieldsprinted;
if(! $sortfield) if(! $sortorder) $object
email_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Object of table llx_c_email_templates.
Class to manage a WYSIWYG editor.
Class to manage Dolibarr users.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
dol_now($mode='gmt')
Return date for now.
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, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
fieldList($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
$context
@method int call_trigger(string $triggerName, ?User $user)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.