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"');
94$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
95$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
97if (empty($page) || $page == -1) {
100$offset = $limit * $page;
101$pageprev = $page - 1;
102$pagenext = $page + 1;
104if (empty($sortfield)) {
105 $sortfield =
'type_template,lang,position,label';
107if (empty($sortorder)) {
112$hookmanager->initHooks(array(
'emailtemplates'));
118$arrayfields = array();
119foreach (
$object->fields as $key => $val) {
121 if (!empty($val[
'visible'])) {
122 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
123 $arrayfields[$tableprefix.
'.'.$key] = array(
124 'label' => $val[
'label'],
125 'checked' => (($visible < 0) ?
'0' :
'1'),
126 'enabled' => (
string) (int) (abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
127 'position' => $val[
'position'],
128 'help' => isset($val[
'help']) ? $val[
'help'] :
''
134if (!empty($user->socid)) {
139$permissiontoedit = ($user->admin ? 1 : 0);
140$permissiontodelete = ($user->admin ? 1 : 0);
144 $result = $tmpmailtemplate->fetch($rowid);
145 if ($tmpmailtemplate->fk_user == $user->id) {
146 $permissiontoedit = 1;
147 $permissiontodelete = 1;
155$tabname[25] = MAIN_DB_PREFIX.
"c_email_templates";
160$tabfield[25] =
"label,lang,type_template,fk_user,position,module,topic,joinfiles,defaultfortype,content";
162 $tabfield[25] .=
',content_lines';
167$tabfieldvalue = array();
168$tabfieldvalue[25] =
"label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
170 $tabfieldvalue[25] .=
',email_to';
173 $tabfieldvalue[25] .=
',email_tocc';
176 $tabfieldvalue[25] .=
',email_tobcc';
179 $tabfieldvalue[25] .=
',content_lines';
184$tabfieldinsert = array();
185$tabfieldinsert[25] =
"label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content,datec";
187 $tabfieldvalue[25] .=
',email_to';
190 $tabfieldvalue[25] .=
',email_tocc';
193 $tabfieldvalue[25] .=
',email_tobcc';
196 $tabfieldinsert[25] .=
',content_lines';
198$tabfieldinsert[25] .=
',entity';
202require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
204 $targetobject = fetchObjectByElement(0, $tmpmailtemplate->type_template);
208 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
209 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
210 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
211 foreach ($tmp as $key => $val) {
212 $helpsubstit .= $key.
' -> '.$val.
'<br>';
213 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
216 $targetobject = fetchObjectByElement(0, $tmpmailtemplate->type_template);
220 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
221 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
222 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
223 foreach ($tmp as $key => $val) {
224 $helpsubstit .= $key.
' -> '.$val.
'<br>';
227 foreach ($tmp as $key => $val) {
228 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
235 'label' => $langs->trans(
'EnterAnyCode'),
236 'type_template' => $langs->trans(
"TemplateForElement"),
237 'private' => $langs->trans(
"TemplateIsVisibleByOwnerOnly"),
238 'position' => $langs->trans(
"PositionIntoComboList"),
239 'topic' =>
'<span class="small">'.$helpsubstit.
'</span>',
240 'email_from' => $langs->trans(
'ForceEmailFrom'),
241 'email_to' => $langs->trans(
'MailTo'),
242 'email_tocc' => $langs->trans(
'MailCC'),
243 'email_tobcc' => $langs->trans(
'MailCCC'),
244 'joinfiles' => $langs->trans(
'AttachMainDocByDefault'),
245 'defaultfortype' => $langs->trans(
"DefaultForTypeDesc"),
246 'content' =>
'<span class="small">'.$helpsubstit.
'</span>',
247 'content_lines' =>
'<span class="small">'.$helpsubstitforlines.
'</span>'
252$elementList = array();
255$elementList[
'all'] =
'-- '.dol_escape_htmltag($langs->trans(
"All")).
' --';
256$elementList[
'none'] =
'-- '.dol_escape_htmltag($langs->trans(
"None")).
' --';
257$elementList[
'user'] =
img_picto(
'',
'user',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToUser'));
258if (
isModEnabled(
'member') && $user->hasRight(
'adherent',
'lire')) {
259 $elementList[
'member'] =
img_picto(
'',
'object_member',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToMember'));
261if (
isModEnabled(
'recruitment') && $user->hasRight(
'recruitment',
'recruitmentjobposition',
'read')) {
262 $elementList[
'recruitmentcandidature_send'] =
img_picto(
'',
'recruitmentcandidature',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'RecruitmentCandidatures'));
264if (
isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')) {
265 $elementList[
'expensereport_send'] =
img_picto(
'',
'trip',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendExpenseReport'));
267if (
isModEnabled(
'holiday') && $user->hasRight(
'holiday',
'read')) {
268 $elementList[
'holiday'] =
img_picto(
'',
'holiday',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendLeaves'));
270if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'lire')) {
271 $elementList[
'thirdparty'] =
img_picto(
'',
'company',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToThirdparty'));
273if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'contact',
'lire')) {
274 $elementList[
'contact'] =
img_picto(
'',
'contact',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToContact'));
277 $elementList[
'project'] =
img_picto(
'',
'project',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToProject'));
279if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
280 $elementList[
'propal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendProposal'));
282if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
283 $elementList[
'order_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendOrder'));
285if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
286 $elementList[
'facture_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendInvoice'));
289 $elementList[
'shipping_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendShipment'));
290 $elementList[
'delivery_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendDelivery'));
293 $elementList[
'reception_send'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendReception'));
296 $elementList[
'fichinter_send'] =
img_picto(
'',
'intervention',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendIntervention'));
299 $elementList[
'supplier_proposal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierRequestForQuotation'));
301if (
isModEnabled(
"supplier_order") && ($user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'read'))) {
302 $elementList[
'order_supplier_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierOrder'));
304if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
305 $elementList[
'invoice_supplier_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierInvoice'));
307if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"write"))) {
308 $elementList[
'supplier_payment_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'SuppliersPayment'));
310if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
311 $elementList[
'contract'] =
img_picto(
'',
'contract',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendContract'));
313if (
isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
314 $elementList[
'ticket_send'] =
img_picto(
'',
'ticket',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToTicket'));
317 $elementList[
'actioncomm_send'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventPush'));
319if (
isModEnabled(
'eventorganization') && $user->hasRight(
'project',
'read')) {
320 $elementList[
'conferenceorbooth'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventOrganization'));
322if (
isModEnabled(
'partnership') && $user->hasRight(
'partnership',
'read')) {
323 $elementList[
'partnership_send'] =
img_picto(
'',
'partnership',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToPartnership'));
325if (
isModEnabled(
'product') && $user->hasRight(
'produit',
'lire')) {
326 $elementList[
'product_send'] =
img_picto(
'',
'product',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'Product'));
329 $elementList[
'stocktransfer_send'] =
'<span class="fas fa-box-open em080 valignmiddle pictomodule paddingrightonly" style="color: #a69944;"></span>'.dol_escape_htmltag($langs->trans(
'MailToSendStockTransfer'));
332$parameters = array(
'elementList' => $elementList);
333$reshook = $hookmanager->executeHooks(
'emailElementlist', $parameters);
335 foreach ($hookmanager->resArray as $item => $value) {
336 $elementList[$item] = $value;
349if (
GETPOST(
'cancel',
'alpha') ||
GETPOST(
'actioncancel',
'alpha')) {
353 if (!empty($backtopage)) {
354 header(
"Location: ".$backtopage);
358if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
362$parameters = array();
364$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
369if (empty($reshook)) {
371 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
374 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
377 $search_type_template =
'';
379 $search_fk_user =
'';
383 $search_array_options = array();
387 if ((
GETPOST(
'actionadd',
'alpha') && $permissiontoadd) || (
GETPOST(
'actionmodify',
'alpha') && $permissiontoedit)) {
388 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[25]));
389 $listfieldinsert = explode(
',', $tabfieldinsert[25]);
390 $listfieldmodify = explode(
',', $tabfieldvalue[25]);
391 $listfieldvalue = explode(
',', $tabfieldvalue[25]);
395 foreach ($listfield as $f => $value) {
397 if (in_array($value, [
'joinfiles',
'defaultfortype',
'content',
'content_lines',
'module',
'tms',
'datec',
'email_to',
'email_tocc',
'email_tobcc'])) {
402 if (
GETPOST(
'actionmodify',
'alpha') && $value ==
'topic') {
403 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
406 if ((!GETPOSTISSET($value) ||
GETPOST($value) ==
'' ||
GETPOST($value) ==
'-1') && $value !=
'lang' && $value !=
'fk_user' && $value !=
'position') {
408 $fieldnamekey = $listfield[$f];
410 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
411 $fieldnamekey =
'Code';
413 if ($fieldnamekey ==
'code') {
414 $fieldnamekey =
'Code';
416 if ($fieldnamekey ==
'note') {
417 $fieldnamekey =
'Note';
419 if ($fieldnamekey ==
'type_template') {
420 $fieldnamekey =
'TypeOfTemplate';
422 if ($fieldnamekey ==
'fk_user') {
423 $fieldnamekey =
'Owner';
425 if ($fieldnamekey ==
'private') {
426 $fieldnamekey =
'Private';
428 if ($fieldnamekey ==
'position') {
429 $fieldnamekey =
'Position';
431 if ($fieldnamekey ==
'topic') {
432 $fieldnamekey =
'Topic';
435 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
441 if ($ok &&
GETPOST(
'actionadd')) {
443 $sql =
"INSERT INTO ".$db->sanitize($tabname[25]).
" (";
445 $sql .= $tabfieldinsert[25];
446 $sql .=
", active, enabled)";
452 foreach ($listfieldinsert as $f => $value) {
453 $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] :
"";
454 if ($value ==
'lang') {
455 $keycode =
'langcode';
457 if (empty($keycode)) {
462 if ($value ==
'entity') {
463 $_POST[$keycode] =
$conf->entity;
465 if ($value ==
'fk_user' && !($_POST[$keycode] > 0)) {
466 $_POST[$keycode] =
'';
468 if ($value ==
'private' && !is_numeric($_POST[$keycode])) {
469 $_POST[$keycode] =
'0';
471 if ($value ==
'position' && !is_numeric($_POST[$keycode])) {
472 $_POST[$keycode] =
'1';
474 if ($value ==
'defaultfortype' && !is_numeric($_POST[$keycode])) {
475 $_POST[$keycode] =
'0';
482 if ($keycode ==
'datec') {
483 $sql .=
"'".$db->idate($now).
"'";
484 } elseif (
GETPOST($keycode) ==
'' && $keycode !=
'langcode') {
486 } elseif (
GETPOST($keycode) ==
'0' && $keycode ==
'langcode') {
488 } elseif ($keycode ==
'fk_user') {
490 $sql .=
" ".((int) $user->id);
492 $sql .=
" ".(GETPOSTINT($keycode));
494 } elseif ($keycode ==
'content') {
495 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
496 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private',
'position',
'entity'))) {
499 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
506 $result =
$db->query($sql);
509 $_POST = array(
'id' => 25);
511 if (!empty($backtopage)) {
512 header(
"Location: ".$backtopage);
516 if (
$db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
517 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
526 if ($ok &&
GETPOST(
'actionmodify')) {
530 setEventMessages($langs->trans(
"AnOwnerMustBeSetIfEmailTemplateIsPrivate"),
null,
'errors');
537 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET ";
540 foreach ($listfieldmodify as $field) {
541 if ($field ==
'entity') {
544 $_POST[$keycode] =
$conf->entity;
546 $keycode = $listfieldvalue[$i];
549 if ($field ==
'lang') {
550 $keycode =
'langcode';
552 if (empty($keycode)) {
557 if ($field ==
'topic') {
558 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
560 if ($field ==
'joinfiles') {
561 $_POST[
'joinfiles'] =
GETPOST(
'joinfiles-'.$rowid);
563 if ($field ==
'content') {
564 $_POST[
'content'] =
GETPOST(
'content-'.$rowid,
'restricthtml');
566 if ($field ==
'content_lines') {
567 $_POST[
'content_lines'] =
GETPOST(
'content_lines-'.$rowid,
'restricthtml');
569 if ($field ==
'email_from') {
570 $_POST[
'email_from'] =
GETPOST(
'email_from-'.$rowid,
'email');
572 if ($field ==
'email_to') {
573 $_POST[
'email_to'] =
GETPOST(
'email_to-'.$rowid,
'email');
575 if ($field ==
'email_tocc') {
576 $_POST[
'email_tocc'] =
GETPOST(
'email_tocc-'.$rowid,
'email');
578 if ($field ==
'email_tobcc') {
579 $_POST[
'email_tobcc'] =
GETPOST(
'email_tobcc-'.$rowid,
'email');
585 $sql .= $field.
" = ";
587 if ((
GETPOST($keycode) ==
'' && in_array($keycode, array(
'langcode'))) || (!in_array($keycode, array(
'langcode',
'position',
'private',
'defaultfortype')) && !
GETPOST($keycode))) {
589 } elseif ($keycode ==
'langcode' && (
GETPOST($keycode) ==
'0' ||
GETPOST($keycode) ==
'-1')) {
591 } elseif ($keycode ==
'fk_user') {
593 $sql .= ((int) $user->id);
597 } elseif ($keycode ==
'content') {
598 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
599 } elseif ($keycode ==
'position') {
601 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private'))) {
604 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
609 $sql .=
" WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
611 $sql .=
" AND fk_user = ".((int) $user->id);
617 $resql =
$db->query($sql);
631 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
634 $sql =
"DELETE from ".$db->sanitize($tabname[25]).
" WHERE rowid = ".((int) $rowid);
636 $sql .=
" AND fk_user = ".((int) $user->id);
639 $result =
$db->query($sql);
641 if (
$db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
642 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
650 if ($action == $acts[0] && $permissiontoedit) {
653 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET active = 1 WHERE rowid = ".((int) $rowid);
655 $result =
$db->query($sql);
662 if ($action == $acts[1] && $permissiontoedit) {
665 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET active = 0 WHERE rowid = ".((int) $rowid);
667 $result =
$db->query($sql);
686if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
687 $title = $langs->trans(
"EMailsSetup");
689 $title = $langs->trans(
"EMailTemplates");
694$sql =
"SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from, email_to, email_tocc, email_tobcc, joinfiles, defaultfortype,";
695$sql .=
" content_lines, content, enabled, active, tms, datec";
696$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_email_templates";
697$sql .=
" WHERE entity IN (".getEntity(
'email_template').
")";
699 $sql .=
" AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id).
"))";
700 $sql .=
" AND (active = 1 OR fk_user = ".((int) $user->id).
")";
703 $sql .=
" AND (lang = '".$db->escape($langs->defaultlang).
"' OR lang IS NULL OR lang = '')";
708if ($search_type_template !=
'' && $search_type_template !=
'-1') {
714if ($search_fk_user !=
'' && $search_fk_user !=
'-1') {
721$listofmodules = implode(
",", array_keys(
$conf->modules));
722$sql .=
"AND (".natural_search(
'module', $listofmodules, 3, 1).
" OR module IS NULL)";
727if ($sortfield ==
'country') {
728 $sortfield =
'country_code';
730$sql .=
$db->order($sortfield, $sortorder);
736llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-admin page-mails_templates');
738$arrayofselected = is_array($toselect) ? $toselect : array();
742 $param .=
'&mode='.urlencode($mode);
744if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
745 $param .=
'&contextpage='.urlencode($contextpage);
747if ($limit > 0 && $limit !=
$conf->liste_limit) {
748 $param .=
'&limit='.((int) $limit);
750if (!empty($search) && is_array($search)) {
751 foreach ($search as $key => $val) {
752 if (is_array($search[$key]) && count($search[$key])) {
753 foreach ($search[$key] as $skey) {
755 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
758 } elseif ($search[$key] !=
'') {
759 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
763if ($optioncss !=
'') {
764 $param .=
'&optioncss='.urlencode($optioncss);
767include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
769$parameters = array();
770$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
771$param .= $hookmanager->resPrint;
774$titlepicto =
'title_setup';
777$url = DOL_URL_ROOT.
'/admin/mails_templates.php?action=create';
779$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewEMailTemplate'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
784 $param .=
'&search_label='.urlencode($search_label);
786if (!empty($search_lang) && $search_lang !=
'-1') {
787 $param .=
'&search_lang='.urlencode($search_lang);
789if ($search_type_template !=
'-1') {
790 $param .=
'&search_type_template='.urlencode($search_type_template);
792if ($search_fk_user > 0) {
793 $param .=
'&search_fk_user='.urlencode($search_fk_user);
796 $param .=
'&search_module='.urlencode($search_module);
799 $param .=
'&search_topic='.urlencode($search_topic);
802$paramwithsearch = $param;
804 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
807 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
810 $paramwithsearch .=
'&limit='.((int) $limit);
813 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
816$massactionbutton =
'';
820dol_syslog(
"htdocs/admin/mails_templates.php", LOG_DEBUG);
822$resql =
$db->query($sql);
828$nbtotalofrecords =
$db->num_rows($resql);
830$sql .=
$db->plimit($limit + 1, $offset);
832$resql =
$db->query($sql);
838$num =
$db->num_rows($resql);
840if ($action !=
'create') {
841 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="list_of_c_email_templates" spellcheck="false">';
842 print
'<input type="hidden" name="token" value="'.newToken().
'">';
843 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
846if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
849 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'tools', 0, $newcardbutton,
'', $limit,
'limit', 0, 1);
852if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
857 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
864if ($action ==
'delete') {
865 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);
869$fieldlist = explode(
',', $tabfield[25]);
871if ($action ==
'create') {
874 $obj->label =
GETPOST(
'label');
876 $obj->type_template =
GETPOST(
'type_template');
879 $obj->position =
GETPOST(
'position');
880 $obj->topic =
GETPOST(
'topic');
881 $obj->joinfiles =
GETPOST(
'joinfiles');
882 $obj->defaultfortype =
GETPOST(
'defaultfortype') ? 1 : 0;
883 $obj->content =
GETPOST(
'content',
'restricthtml');
886 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="create_c_email_template" spellcheck="false">';
887 print
'<input type="hidden" name="token" value="'.newToken().
'">';
888 print
'<input type="hidden" name="action" value="add">';
889 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
890 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
892 print
'<div class="div-table-responsive-no-min">';
893 print
'<table class="noborder centpercent" id="table_create_c_email_template">';
896 print
'<tr class="liste_titre">';
897 foreach ($fieldlist as $field => $value) {
900 $valuetoshow = ucfirst($fieldlist[$field]);
901 $valuetoshow = $langs->trans($valuetoshow);
903 if ($fieldlist[$field] ==
'module') {
904 $valuetoshow =
' ';
906 if ($fieldlist[$field] ==
'fk_user') {
907 $valuetoshow = $langs->trans(
"Owner");
909 if ($fieldlist[$field] ==
'lang') {
910 $valuetoshow = (!
getDolGlobalInt(
'MAIN_MULTILANGS') ?
' ' : $langs->trans(
"Language"));
912 if ($fieldlist[$field] ==
'type') {
913 $valuetoshow = $langs->trans(
"Type");
915 if ($fieldlist[$field] ==
'position') {
918 if ($fieldlist[$field] ==
'code') {
919 $valuetoshow = $langs->trans(
"Code");
921 if ($fieldlist[$field] ==
'label') {
922 $valuetoshow = $langs->trans(
"Label");
924 if ($fieldlist[$field] ==
'type_template') {
925 $valuetoshow = $langs->trans(
"TypeOfTemplate");
928 if (in_array($fieldlist[$field], array(
'private',
'private',
'defaultfortype'))) {
932 if ($fieldlist[$field] ==
'topic') {
935 if ($fieldlist[$field] ==
'joinfiles') {
938 if ($fieldlist[$field] ==
'content') {
941 if ($fieldlist[$field] ==
'content_lines') {
944 if ($valuetoshow !=
'') {
945 print
'<th class="'.$css.
'">';
946 if (!empty($tabhelp[25][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[25][$value])) {
947 print
'<a href="'.$tabhelp[25][$value].
'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
948 } elseif (!empty($tabhelp[25][$value])) {
949 if (in_array($value, array(
'topic'))) {
950 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2, $value);
952 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2);
964 $tmpaction =
'create';
966 'fieldlist' => $fieldlist,
967 'tabname' => $tabname[25]
969 $reshook = $hookmanager->executeHooks(
'createEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
970 $error = $hookmanager->error;
971 $errors = $hookmanager->errors;
975 print
'<tr class="oddeven">';
977 if (empty($reshook)) {
978 if ($action ==
'edit') {
979 fieldList($fieldlist, $obj, $tabname[25],
'hide');
981 fieldList($fieldlist, $obj, $tabname[25],
'add');
985 print
'<td class="right">';
989 print
'<tr class="oddeven nodrag nodrop nohover"><td colspan="9" style="padding-left: 20px; padding-right: 20px;">';
992 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
994 $fieldsforcontent[] =
'email_to';
997 $fieldsforcontent[] =
'email_tocc';
1000 $fieldsforcontent[] =
'email_tobcc';
1003 $fieldsforcontent[] =
'content_lines';
1005 foreach ($fieldsforcontent as $tmpfieldlist) {
1006 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
1008 if ($tmpfieldlist ==
'topic') {
1009 print
'<span class="bold minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1011 if ($tmpfieldlist ==
'email_from') {
1012 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1014 if ($tmpfieldlist ==
'email_to') {
1015 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailTo"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1017 if ($tmpfieldlist ==
'email_tocc') {
1018 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailCC"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1020 if ($tmpfieldlist ==
'email_tobcc') {
1021 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailCCC"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1023 if ($tmpfieldlist ==
'joinfiles') {
1024 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
1026 if ($tmpfieldlist ==
'content') {
1027 print
'<span class="minwidth150 inline-block margintoponly">'.$form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
1029 if ($tmpfieldlist ==
'content_lines') {
1030 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
1034 if ($tmpfieldlist ==
'topic') {
1035 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'">';
1036 } elseif ($tmpfieldlist ==
'email_from') {
1037 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
1038 } elseif ($tmpfieldlist ==
'email_to') {
1039 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
1040 } elseif ($tmpfieldlist ==
'email_tocc') {
1041 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
1042 } elseif ($tmpfieldlist ==
'email_tobcc') {
1043 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
1044 } elseif ($tmpfieldlist ==
'joinfiles') {
1045 print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, false, 0, 1);
1047 $okforextended =
true;
1049 $okforextended =
false;
1051 $doleditor =
new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
''),
'', 400,
'dolibarr_mailings',
'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'90%');
1052 print $doleditor->Create(1);
1062 if ($action !=
'edit') {
1064 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'"> ';
1065 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
1072 print
'<br><br><br>';
1076print
'<div class="div-table-responsive-no-min">';
1077print
'<table class="noborder centpercent" id="table_list_of_c_email_templates">';
1091print
'<tr class="liste_titre" id="Title line with search boxes">';
1093if (
$conf->main_checkbox_left_column) {
1094 print
'<td class="liste_titre center" width="64">';
1095 $searchpicto = $form->showFilterButtons();
1099foreach ($fieldlist as $field => $value) {
1100 if ($value ==
'module') {
1101 print
'<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).
'" spellcheck="false"></td>';
1102 } elseif ($value ==
'label') {
1103 print
'<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).
'" spellcheck="false"></td>';
1104 } elseif ($value ==
'lang') {
1105 print
'<td class="liste_titre">';
1106 print $formadmin->select_language($search_lang,
'search_lang', 0, array(), 1, 0, 0,
'maxwidth100');
1108 } elseif ($value ==
'fk_user') {
1109 print
'<td class="liste_titre">';
1110 print $form->select_dolusers($search_fk_user,
'search_fk_user', 1,
null, 0, ($user->admin ?
'' :
'hierarchyme'), array(),
'0', 0, 0,
'', 0,
'',
'maxwidth100', 1);
1112 } elseif ($value ==
'topic') {
1113 print
'<td class="liste_titre"><input type="text" class="maxwidth150" name="search_topic" value="'.dol_escape_htmltag($search_topic).
'" spellcheck="false"></td>';
1114 } elseif ($value ==
'type_template') {
1115 print
'<td class="liste_titre center">';
1117 print $form->selectarray(
'search_type_template', $elementList, $search_type_template, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125', 1,
'', 0, 1);
1119 } elseif (!in_array($value, array(
'content',
'content_lines'))) {
1120 print
'<td class="liste_titre"></td>';
1130if (!empty($arrayfields[
't.tms'][
'checked'])) {
1133if (!empty($arrayfields[
't.datec'][
'checked'])) {
1137if (!
$conf->main_checkbox_left_column) {
1138 print
'<td class="liste_titre center" width="64">';
1139 $searchpicto = $form->showFilterButtons();
1146print
'<tr class="liste_titre" id="Title of lines">';
1148if (
$conf->main_checkbox_left_column) {
1151array_push($fieldlist,
"tms",
"datec");
1152foreach ($fieldlist as $field => $value) {
1165 $valuetoshow = ucfirst($fieldlist[$field]);
1166 $valuetoshow = $langs->trans($valuetoshow);
1167 if ($fieldlist[$field] ==
'module') {
1168 $css =
'tdoverflowmax100';
1170 if ($fieldlist[$field] ==
'fk_user') {
1171 $valuetoshow = $langs->trans(
"Owner");
1173 if ($fieldlist[$field] ==
'lang') {
1174 $valuetoshow = $langs->trans(
"Language");
1176 if ($fieldlist[$field] ==
'type') {
1177 $valuetoshow = $langs->trans(
"Type");
1179 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
1180 $valuetoshow = $langs->trans(
"Label");
1182 if ($fieldlist[$field] ==
'type_template') {
1184 $valuetoshow = $langs->trans(
"TypeOfTemplate");
1186 if ($fieldlist[$field] ==
'private') {
1189 if ($fieldlist[$field] ==
'position') {
1192 if ($fieldlist[$field] ==
'tms') {
1193 $valuetoshow =
'Modif. date';
1195 if ($fieldlist[$field] ==
'datec') {
1196 $valuetoshow =
'Date creation';
1199 if ($fieldlist[$field] ==
'joinfiles') {
1200 $valuetoshow = $langs->trans(
"FilesAttachedToEmail");
1204 if ($fieldlist[$field] ==
'content') {
1205 $valuetoshow = $langs->trans(
"Content");
1208 if ($fieldlist[$field] ==
'content_lines') {
1209 $valuetoshow = $langs->trans(
"ContentForLines");
1212 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1215 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1221 if (!empty($tabhelp[25][$value])) {
1222 if (in_array($value, array(
'topic'))) {
1223 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'tooltip'.$value, $forcenowrap);
1225 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'', $forcenowrap);
1228 $sortfieldtouse = ($sortable ? $fieldlist[$field] :
'');
1229 if ($sortfieldtouse ==
'type_template') {
1230 $sortfieldtouse .=
',lang,position,label';
1232 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], $sortfieldtouse, ($page ?
'page='.$page.
'&' :
''), $paramwithsearch,
'', $sortfield, $sortorder, $css.
' ');
1236print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $paramwithsearch,
'', $sortfield, $sortorder,
'center ');
1238if (!
$conf->main_checkbox_left_column) {
1247 $obj =
$db->fetch_object($resql);
1250 if (($action ==
'edit' || $action ==
'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1252 print
'<tr class="nohover oddeven noborderbottom" id="rowid-'.$obj->rowid.
'" name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'">';
1254 $tmpaction =
'edit';
1255 if ($action ==
'edit') {
1257 $fieldlist = explode(
',', $tabfield[25]);
1258 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1260 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1262 $reshook = $hookmanager->executeHooks(
'editEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1263 $error = $hookmanager->error;
1264 $errors = $hookmanager->errors;
1269 if (
$conf->main_checkbox_left_column) {
1270 print
'<td class="center">';
1275 if (empty($reshook)) {
1276 $colspan +=
fieldList($fieldlist, $obj, $tabname[25], $action);
1279 if (!
$conf->main_checkbox_left_column) {
1280 print
'<td class="center">';
1286 print
'<tr class="oddeven nohover" id="tr-aaa-'.$rowid.
'">';
1287 if (
$conf->main_checkbox_left_column) {
1288 print
'<td class="center"></td>';
1290 print
'<td colspan="'.($colspan - 1).
'" class="" style="padding-left: 20px; padding-right: 20px;">';
1292 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
1294 $fieldsforcontent[] =
'email_to';
1297 $fieldsforcontent[] =
'email_tocc';
1300 $fieldsforcontent[] =
'email_tobcc';
1303 $fieldsforcontent[] =
'content_lines';
1306 $parameters = array(
'fieldsforcontent' => &$fieldsforcontent,
'tabname' => $tabname[25]);
1307 $hookmanager->executeHooks(
'editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction);
1309 print
'<div class="lineformailtemplatefield centpercent">';
1310 foreach ($fieldsforcontent as $tmpfieldlist) {
1313 $valuetoshow = $obj->$tmpfieldlist;
1318 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
1320 if ($tmpfieldlist ==
'topic') {
1321 print
'<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1322 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
'>';
1325 if ($tmpfieldlist ==
'email_from') {
1326 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1327 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1330 if ($tmpfieldlist ==
'email_to') {
1331 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailTo"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1332 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1335 if ($tmpfieldlist ==
'email_tocc') {
1336 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailCC"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1337 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1340 if ($tmpfieldlist ==
'email_tobcc') {
1341 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailCCC"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1342 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1345 if ($tmpfieldlist ==
'joinfiles') {
1346 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1347 print $form->selectyesno($tmpfieldlist.
'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, ($action !=
'edit'), 0, 1);
1351 if ($tmpfieldlist ==
'content') {
1352 print $form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1353 $okforextended =
true;
1355 $okforextended =
false;
1357 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 450,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%', ($action !=
'edit' ? 1 : 0));
1358 print $doleditor->Create(1);
1360 if ($tmpfieldlist ==
'content_lines') {
1362 print $form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1363 $okforextended =
true;
1365 $okforextended =
false;
1367 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 140,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%');
1368 print $doleditor->Create(1);
1374 print
'<center><input type="hidden" name="page" value="'.$page.
'">';
1375 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
1376 if ($action ==
'edit') {
1377 print
'<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans(
"Save").
'">';
1379 print
'<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
1383 if (!
$conf->main_checkbox_left_column) {
1384 print
'<td class="center"></td>';
1393 $tempmodulekey = $obj->module;
1400 $keyforobj =
'type_template';
1401 if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1406 if (! (
int)
dol_eval((
string) $obj->enabled, 1, 1,
'1')) {
1417 if (!$user->admin && $obj->fk_user != $user->id) {
1423 $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) :
'');
1428 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
1431 if (
$conf->main_checkbox_left_column) {
1432 print
'<td class="center nowraponall" width="64">';
1433 if ($canbemodified) {
1434 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
1436 print
'<a class="reposition editfielda" href="'.$url.
'&action=preview&token='.
newToken().
'">'.
img_view().
'</a>';
1439 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.
newToken().$param.
'">'.
img_delete().
'</a>';
1444 $tmpaction =
'view';
1445 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1446 $reshook = $hookmanager->executeHooks(
'viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1448 $error = $hookmanager->error;
1449 $errors = $hookmanager->errors;
1451 if (empty($reshook)) {
1452 foreach ($fieldlist as $field => $value) {
1453 if (in_array($fieldlist[$field], array(
'content',
'content_lines'))) {
1460 $tmpvar = $fieldlist[$field];
1461 $valuetoshow = $obj->$tmpvar;
1462 if ($value ==
'label' || $value ==
'topic') {
1463 if ($langs->trans($valuetoshow) != $valuetoshow) {
1464 $valuetoshow = $langs->trans($valuetoshow);
1468 if ($value ==
'label') {
1469 $class .=
' tdoverflowmax200';
1471 if ($value ==
'topic') {
1472 $class .=
' tdoverflowmax200 small';
1474 if ($value ==
'type_template') {
1475 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1476 $css =
"center tdoverflowmax150";
1478 if ($value ==
'lang' && $valuetoshow) {
1479 $valuetoshow = $valuetoshow.
' - '.$langs->trans(
"Language_".$valuetoshow);
1480 $class .=
' tdoverflowmax100';
1482 if ($value ==
'fk_user') {
1483 if ($valuetoshow > 0) {
1485 $fuser->fetch($valuetoshow);
1486 $valuetoshow = $fuser->getNomUrl(-1);
1488 if ($obj->private) {
1489 $valuetoshow =
img_picto($langs->transnoentitiesnoconv(
"Private"),
'lock',
'class="pictofixedwidth"').$valuetoshow;
1492 $class .=
' tdoverflowmax100';
1495 if ($value ==
'private') {
1498 $valuetoshow =
yn($valuetoshow);
1503 if ($value ==
'position') {
1506 if (in_array($value, array(
'joinfiles',
'defaultfortype'))) {
1510 $valuetoshow =
'<input type="checkbox" checked="checked" disabled>';
1519 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1522 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1528 print
'<!-- '.$fieldlist[$field].
' -->';
1529 print
'<td class="'.$class.
'"';
1530 if (in_array($value, array(
'code',
'label',
'topic'))) {
1531 print
' title="'.dol_escape_htmltag($valuetoshow).
'"';
1541 print
'<td class="center nowrap">';
1542 if ($canbedisabled) {
1543 print
'<a class="reposition" href="'.$url.
'&action='.$acts[$obj->active].
'&token='.
newToken().
'">'.$actl[$obj->active].
'</a>';
1545 print
'<span class="opacitymedium">'.$actl[$obj->active].
'</span>';
1550 if (!
$conf->main_checkbox_left_column) {
1551 print
'<td class="center nowraponall" width="64">';
1552 if ($canbemodified) {
1553 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
1556 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
1571if ($nbqualified == 0) {
1573 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1579if ($action !=
'create') {
1583if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
1604 global $langs, $user,
$db;
1606 global $elementList;
1609 $nboffieldsprinted = 0;
1611 foreach ($fieldlist as $value) {
1613 if ($value ==
'module') {
1615 $nboffieldsprinted++;
1616 } elseif ($value ==
'fk_user') {
1618 if ($user->admin &&
$context !=
'preview') {
1619 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');
1622 print $user->getNomUrl(-1);
1623 $forcedvalue = $user->id;
1625 if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1627 $fuser->fetch($obj->$value);
1628 print $fuser->getNomUrl(-1);
1629 $forcedvalue = $fuser->id;
1631 $forcedvalue = $obj->$value;
1635 print
'<input type="hidden" value="'.$forcedvalue.
'" name="'.$keyname.
'">';
1638 $nboffieldsprinted++;
1639 } elseif ($value ==
'lang') {
1642 $selectedlang = GETPOSTISSET(
'langcode') ?
GETPOST(
'langcode',
'aZ09') : $langs->defaultlang;
1644 $selectedlang = $obj->lang;
1646 print $formadmin->select_language($selectedlang,
'langcode', 0, array(), $langs->trans(
"Language"), 0, 0,
'maxwidth100');
1648 if (!empty($obj->lang)) {
1649 print $obj->lang.
' - '.$langs->trans(
'Language_'.$obj->lang);
1652 if ($keyname ==
'lang') {
1653 $keyname =
'langcode';
1655 print
'<input type="hidden" value="'.(empty($obj->lang) ?
'' : $obj->lang).
'" name="'.$keyname.
'">';
1658 $nboffieldsprinted++;
1659 } elseif ($value ==
'type_template') {
1661 print
'<td class="center">';
1662 if ((
$context ==
'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) ||
$context ==
'preview') {
1664 print
'<input type="hidden" name="type_template" value="'.$obj->type_template.
'">';
1665 print $obj->type_template;
1667 print $form->selectarray(
'type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 maxwidth125', 1,
'', 0, 1);
1670 $nboffieldsprinted++;
1671 } elseif (
$context ==
'add' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1673 } elseif (
$context ==
'edit' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1675 $nboffieldsprinted++;
1676 } elseif (
$context ==
'preview' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1678 $nboffieldsprinted++;
1679 } elseif (
$context ==
'hide' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1685 if ($value ==
'code') {
1686 $class =
'maxwidth100';
1688 if ($value ==
'label') {
1689 $class =
'maxwidth200';
1691 if ($value ==
'private') {
1692 $class =
'maxwidth50';
1693 $classtd =
'center';
1695 if ($value ==
'position') {
1696 $class =
'maxwidth50 center';
1697 $classtd =
'center';
1699 if ($value ==
'topic') {
1700 $class =
'quatrevingtpercent';
1702 if ($value ==
'defaultfortype') {
1703 $class =
'width25 center';
1704 $classtd =
'center';
1707 print
'<td'.($classtd ?
' class="'.$classtd.
'"' :
'').
'>';
1708 if (in_array($value, array(
'defaultfortype',
'private')) &&
$context !=
'preview') {
1709 if (empty($user->admin)) {
1711 print $form->selectyesno($value, GETPOSTISSET($value) ?
GETPOSTINT($value) : ((
$context !=
'add' && isset($obj->$value)) ? $obj->$value :
'1'), 1,
false, 0, 1);
1714 print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value :
''), 1,
false, 0, 1);
1717 print
'<input type="text" '.$size.
'class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->$value) ? $obj->$value :
'').
'" name="'. $value .
'"'.(
$context ==
'preview' ?
' disabled' :
'').
' spellcheck="false">';
1720 $nboffieldsprinted++;
1724 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.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
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.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
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.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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.