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] .=
',content_lines';
175$tabfieldinsert = array();
176$tabfieldinsert[25] =
"label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content,datec";
178 $tabfieldinsert[25] .=
',content_lines';
180$tabfieldinsert[25] .=
',entity';
184require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
186 $targetobject = fetchObjectByElement(0, $tmpmailtemplate->type_template);
190 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
191 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
192 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
193 foreach ($tmp as $key => $val) {
194 $helpsubstit .= $key.
' -> '.$val.
'<br>';
195 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
198 $targetobject = fetchObjectByElement(0, $tmpmailtemplate->type_template);
202 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
203 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
204 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
205 foreach ($tmp as $key => $val) {
206 $helpsubstit .= $key.
' -> '.$val.
'<br>';
209 foreach ($tmp as $key => $val) {
210 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
217 'label' => $langs->trans(
'EnterAnyCode'),
218 'type_template' => $langs->trans(
"TemplateForElement"),
219 'private' => $langs->trans(
"TemplateIsVisibleByOwnerOnly"),
220 'position' => $langs->trans(
"PositionIntoComboList"),
221 'topic' =>
'<span class="small">'.$helpsubstit.
'</span>',
222 'email_from' => $langs->trans(
'ForceEmailFrom'),
223 'joinfiles' => $langs->trans(
'AttachMainDocByDefault'),
224 'defaultfortype' => $langs->trans(
"DefaultForTypeDesc"),
225 'content' =>
'<span class="small">'.$helpsubstit.
'</span>',
226 'content_lines' =>
'<span class="small">'.$helpsubstitforlines.
'</span>'
231$elementList = array();
234$elementList[
'all'] =
'-- '.dol_escape_htmltag($langs->trans(
"All")).
' --';
235$elementList[
'none'] =
'-- '.dol_escape_htmltag($langs->trans(
"None")).
' --';
236$elementList[
'user'] =
img_picto(
'',
'user',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToUser'));
237if (
isModEnabled(
'member') && $user->hasRight(
'adherent',
'lire')) {
238 $elementList[
'member'] =
img_picto(
'',
'object_member',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToMember'));
240if (
isModEnabled(
'recruitment') && $user->hasRight(
'recruitment',
'recruitmentjobposition',
'read')) {
241 $elementList[
'recruitmentcandidature_send'] =
img_picto(
'',
'recruitmentcandidature',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'RecruitmentCandidatures'));
243if (
isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')) {
244 $elementList[
'expensereport_send'] =
img_picto(
'',
'trip',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendExpenseReport'));
246if (
isModEnabled(
'holiday') && $user->hasRight(
'holiday',
'read')) {
247 $elementList[
'holiday'] =
img_picto(
'',
'holiday',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendLeaves'));
249if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'lire')) {
250 $elementList[
'thirdparty'] =
img_picto(
'',
'company',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToThirdparty'));
252if (
isModEnabled(
"societe") && $user->hasRight(
'societe',
'contact',
'lire')) {
253 $elementList[
'contact'] =
img_picto(
'',
'contact',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToContact'));
256 $elementList[
'project'] =
img_picto(
'',
'project',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToProject'));
258if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
259 $elementList[
'propal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendProposal'));
261if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
262 $elementList[
'order_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendOrder'));
264if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
265 $elementList[
'facture_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendInvoice'));
268 $elementList[
'shipping_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendShipment'));
269 $elementList[
'delivery_send'] =
img_picto(
'',
'dolly',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendDelivery'));
272 $elementList[
'reception_send'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendReception'));
275 $elementList[
'fichinter_send'] =
img_picto(
'',
'intervention',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendIntervention'));
278 $elementList[
'supplier_proposal_send'] =
img_picto(
'',
'propal',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierRequestForQuotation'));
280if (
isModEnabled(
"supplier_order") && ($user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'read'))) {
281 $elementList[
'order_supplier_send'] =
img_picto(
'',
'order',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierOrder'));
283if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
284 $elementList[
'invoice_supplier_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierInvoice'));
286if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
"supplier_invoice",
"write"))) {
287 $elementList[
'supplier_payment_send'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'SuppliersPayment'));
289if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
290 $elementList[
'contract'] =
img_picto(
'',
'contract',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendContract'));
292if (
isModEnabled(
'ticket') && $user->hasRight(
'ticket',
'read')) {
293 $elementList[
'ticket_send'] =
img_picto(
'',
'ticket',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToTicket'));
296 $elementList[
'actioncomm_send'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventPush'));
298if (
isModEnabled(
'eventorganization') && $user->hasRight(
'project',
'read')) {
299 $elementList[
'conferenceorbooth'] =
img_picto(
'',
'action',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToSendEventOrganization'));
301if (
isModEnabled(
'partnership') && $user->hasRight(
'partnership',
'read')) {
302 $elementList[
'partnership_send'] =
img_picto(
'',
'partnership',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'MailToPartnership'));
304if (
isModEnabled(
'product') && $user->hasRight(
'produit',
'lire')) {
305 $elementList[
'product_send'] =
img_picto(
'',
'product',
'class="pictofixedwidth"').dol_escape_htmltag($langs->trans(
'Product'));
308 $elementList[
'stocktransfer_send'] =
'<span class="fas fa-box-open em080 valignmiddle pictomodule paddingrightonly" style="color: #a69944;"></span>'.dol_escape_htmltag($langs->trans(
'MailToSendStockTransfer'));
311$parameters = array(
'elementList' => $elementList);
312$reshook = $hookmanager->executeHooks(
'emailElementlist', $parameters);
314 foreach ($hookmanager->resArray as $item => $value) {
315 $elementList[$item] = $value;
328if (
GETPOST(
'cancel',
'alpha') ||
GETPOST(
'actioncancel',
'alpha')) {
332 if (!empty($backtopage)) {
333 header(
"Location: ".$backtopage);
337if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
341$parameters = array();
343$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
348if (empty($reshook)) {
350 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
353 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
356 $search_type_template =
'';
358 $search_fk_user =
'';
362 $search_array_options = array();
366 if ((
GETPOST(
'actionadd',
'alpha') && $permissiontoadd) || (
GETPOST(
'actionmodify',
'alpha') && $permissiontoedit)) {
367 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[25]));
368 $listfieldinsert = explode(
',', $tabfieldinsert[25]);
369 $listfieldmodify = explode(
',', $tabfieldvalue[25]);
370 $listfieldvalue = explode(
',', $tabfieldvalue[25]);
374 foreach ($listfield as $f => $value) {
376 if (in_array($value, [
'joinfiles',
'defaultfortype',
'content',
'content_lines',
'module',
'tms',
'datec'])) {
381 if (
GETPOST(
'actionmodify',
'alpha') && $value ==
'topic') {
382 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
385 if ((!GETPOSTISSET($value) ||
GETPOST($value) ==
'' ||
GETPOST($value) ==
'-1') && $value !=
'lang' && $value !=
'fk_user' && $value !=
'position') {
387 $fieldnamekey = $listfield[$f];
389 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
390 $fieldnamekey =
'Code';
392 if ($fieldnamekey ==
'code') {
393 $fieldnamekey =
'Code';
395 if ($fieldnamekey ==
'note') {
396 $fieldnamekey =
'Note';
398 if ($fieldnamekey ==
'type_template') {
399 $fieldnamekey =
'TypeOfTemplate';
401 if ($fieldnamekey ==
'fk_user') {
402 $fieldnamekey =
'Owner';
404 if ($fieldnamekey ==
'private') {
405 $fieldnamekey =
'Private';
407 if ($fieldnamekey ==
'position') {
408 $fieldnamekey =
'Position';
410 if ($fieldnamekey ==
'topic') {
411 $fieldnamekey =
'Topic';
414 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
420 if ($ok &&
GETPOST(
'actionadd')) {
422 $sql =
"INSERT INTO ".$db->sanitize($tabname[25]).
" (";
424 $sql .= $tabfieldinsert[25];
425 $sql .=
", active, enabled)";
431 foreach ($listfieldinsert as $f => $value) {
432 $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] :
"";
433 if ($value ==
'lang') {
434 $keycode =
'langcode';
436 if (empty($keycode)) {
441 if ($value ==
'entity') {
442 $_POST[$keycode] =
$conf->entity;
444 if ($value ==
'fk_user' && !($_POST[$keycode] > 0)) {
445 $_POST[$keycode] =
'';
447 if ($value ==
'private' && !is_numeric($_POST[$keycode])) {
448 $_POST[$keycode] =
'0';
450 if ($value ==
'position' && !is_numeric($_POST[$keycode])) {
451 $_POST[$keycode] =
'1';
453 if ($value ==
'defaultfortype' && !is_numeric($_POST[$keycode])) {
454 $_POST[$keycode] =
'0';
461 if ($keycode ==
'datec') {
462 $sql .=
"'".$db->idate($now).
"'";
463 } elseif (
GETPOST($keycode) ==
'' && $keycode !=
'langcode') {
465 } elseif (
GETPOST($keycode) ==
'0' && $keycode ==
'langcode') {
467 } elseif ($keycode ==
'fk_user') {
469 $sql .=
" ".((int) $user->id);
471 $sql .=
" ".(GETPOSTINT($keycode));
473 } elseif ($keycode ==
'content') {
474 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
475 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private',
'position',
'entity'))) {
478 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
485 $result =
$db->query($sql);
488 $_POST = array(
'id' => 25);
490 if (!empty($backtopage)) {
491 header(
"Location: ".$backtopage);
495 if (
$db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
496 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
505 if ($ok &&
GETPOST(
'actionmodify')) {
509 setEventMessages($langs->trans(
"AnOwnerMustBeSetIfEmailTemplateIsPrivate"),
null,
'errors');
516 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET ";
519 foreach ($listfieldmodify as $field) {
520 if ($field ==
'entity') {
523 $_POST[$keycode] =
$conf->entity;
525 $keycode = $listfieldvalue[$i];
528 if ($field ==
'lang') {
529 $keycode =
'langcode';
531 if (empty($keycode)) {
536 if ($field ==
'topic') {
537 $_POST[
'topic'] =
GETPOST(
'topic-'.$rowid);
539 if ($field ==
'joinfiles') {
540 $_POST[
'joinfiles'] =
GETPOST(
'joinfiles-'.$rowid);
542 if ($field ==
'content') {
543 $_POST[
'content'] =
GETPOST(
'content-'.$rowid,
'restricthtml');
545 if ($field ==
'content_lines') {
546 $_POST[
'content_lines'] =
GETPOST(
'content_lines-'.$rowid,
'restricthtml');
548 if ($field ==
'email_from') {
549 $_POST[
'email_from'] =
GETPOST(
'email_from-'.$rowid,
'restricthtml');
555 $sql .= $field.
" = ";
557 if ((
GETPOST($keycode) ==
'' && in_array($keycode, array(
'langcode'))) || (!in_array($keycode, array(
'langcode',
'position',
'private',
'defaultfortype')) && !
GETPOST($keycode))) {
559 } elseif ($keycode ==
'langcode' && (
GETPOST($keycode) ==
'0' ||
GETPOST($keycode) ==
'-1')) {
561 } elseif ($keycode ==
'fk_user') {
563 $sql .= ((int) $user->id);
567 } elseif ($keycode ==
'content') {
568 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
569 } elseif ($keycode ==
'position') {
571 } elseif (in_array($keycode, array(
'joinfiles',
'defaultfortype',
'private'))) {
574 $sql .=
"'".$db->escape(
GETPOST($keycode,
'alphanohtml')).
"'";
579 $sql .=
" WHERE ".$db->escape($rowidcol).
" = ".((int) $rowid);
581 $sql .=
" AND fk_user = ".((int) $user->id);
587 $resql =
$db->query($sql);
601 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
604 $sql =
"DELETE from ".$db->sanitize($tabname[25]).
" WHERE rowid = ".((int) $rowid);
606 $sql .=
" AND fk_user = ".((int) $user->id);
609 $result =
$db->query($sql);
611 if (
$db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
612 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
620 if ($action == $acts[0] && $permissiontoedit) {
623 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET active = 1 WHERE rowid = ".((int) $rowid);
625 $result =
$db->query($sql);
632 if ($action == $acts[1] && $permissiontoedit) {
635 $sql =
"UPDATE ".$db->sanitize($tabname[25]).
" SET active = 0 WHERE rowid = ".((int) $rowid);
637 $result =
$db->query($sql);
656if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
657 $title = $langs->trans(
"EMailsSetup");
659 $title = $langs->trans(
"EMailTemplates");
664$sql =
"SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from, joinfiles, defaultfortype,";
665$sql .=
" content_lines, content, enabled, active, tms, datec";
666$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_email_templates";
667$sql .=
" WHERE entity IN (".getEntity(
'email_template').
")";
669 $sql .=
" AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id).
"))";
670 $sql .=
" AND (active = 1 OR fk_user = ".((int) $user->id).
")";
673 $sql .=
" AND (lang = '".$db->escape($langs->defaultlang).
"' OR lang IS NULL OR lang = '')";
678if ($search_type_template !=
'' && $search_type_template !=
'-1') {
684if ($search_fk_user !=
'' && $search_fk_user !=
'-1') {
691$listofmodules = implode(
",", array_keys(
$conf->modules));
692$sql .=
"AND (".natural_search(
'module', $listofmodules, 3, 1).
" OR module IS NULL)";
697if ($sortfield ==
'country') {
698 $sortfield =
'country_code';
700$sql .=
$db->order($sortfield, $sortorder);
706llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-admin page-mails_templates');
708$arrayofselected = is_array($toselect) ? $toselect : array();
712 $param .=
'&mode='.urlencode($mode);
714if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
715 $param .=
'&contextpage='.urlencode($contextpage);
717if ($limit > 0 && $limit !=
$conf->liste_limit) {
718 $param .=
'&limit='.((int) $limit);
720if (!empty($search) && is_array($search)) {
721 foreach ($search as $key => $val) {
722 if (is_array($search[$key]) && count($search[$key])) {
723 foreach ($search[$key] as $skey) {
725 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
728 } elseif ($search[$key] !=
'') {
729 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
733if ($optioncss !=
'') {
734 $param .=
'&optioncss='.urlencode($optioncss);
737include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
739$parameters = array();
740$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
741$param .= $hookmanager->resPrint;
744$titlepicto =
'title_setup';
747$url = DOL_URL_ROOT.
'/admin/mails_templates.php?action=create';
749$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewEMailTemplate'),
'',
'fa fa-plus-circle', $url,
'', (
int) $permissiontoadd);
754 $param .=
'&search_label='.urlencode($search_label);
756if (!empty($search_lang) && $search_lang !=
'-1') {
757 $param .=
'&search_lang='.urlencode($search_lang);
759if ($search_type_template !=
'-1') {
760 $param .=
'&search_type_template='.urlencode($search_type_template);
762if ($search_fk_user > 0) {
763 $param .=
'&search_fk_user='.urlencode($search_fk_user);
766 $param .=
'&search_module='.urlencode($search_module);
769 $param .=
'&search_topic='.urlencode($search_topic);
772$paramwithsearch = $param;
774 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
777 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
780 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
783$massactionbutton =
'';
787dol_syslog(
"htdocs/admin/mails_templates.php", LOG_DEBUG);
789$resql =
$db->query($sql);
795$nbtotalofrecords =
$db->num_rows($resql);
797$sql .=
$db->plimit($limit + 1, $offset);
799$resql =
$db->query($sql);
805$num =
$db->num_rows($resql);
807if ($action !=
'create') {
808 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="list_of_c_email_templates">';
809 print
'<input type="hidden" name="token" value="'.newToken().
'">';
810 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
813if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
817 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'tools', 0, $newcardbutton,
'', $limit,
'limit', 0, 1);
820if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
825 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
832if ($action ==
'delete') {
833 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);
837$fieldlist = explode(
',', $tabfield[25]);
839if ($action ==
'create') {
842 $obj->label =
GETPOST(
'label');
844 $obj->type_template =
GETPOST(
'type_template');
847 $obj->position =
GETPOST(
'position');
848 $obj->topic =
GETPOST(
'topic');
849 $obj->joinfiles =
GETPOST(
'joinfiles');
850 $obj->defaultfortype =
GETPOST(
'defaultfortype') ? 1 : 0;
851 $obj->content =
GETPOST(
'content',
'restricthtml');
854 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" id="create_c_email_template">';
855 print
'<input type="hidden" name="token" value="'.newToken().
'">';
856 print
'<input type="hidden" name="action" value="add">';
857 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
858 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
860 print
'<div class="div-table-responsive-no-min">';
861 print
'<table class="noborder centpercent" id="table_create_c_email_template">';
864 print
'<tr class="liste_titre">';
865 foreach ($fieldlist as $field => $value) {
868 $valuetoshow = ucfirst($fieldlist[$field]);
869 $valuetoshow = $langs->trans($valuetoshow);
871 if ($fieldlist[$field] ==
'module') {
872 $valuetoshow =
' ';
874 if ($fieldlist[$field] ==
'fk_user') {
875 $valuetoshow = $langs->trans(
"Owner");
877 if ($fieldlist[$field] ==
'lang') {
878 $valuetoshow = (!
getDolGlobalInt(
'MAIN_MULTILANGS') ?
' ' : $langs->trans(
"Language"));
880 if ($fieldlist[$field] ==
'type') {
881 $valuetoshow = $langs->trans(
"Type");
883 if ($fieldlist[$field] ==
'position') {
886 if ($fieldlist[$field] ==
'code') {
887 $valuetoshow = $langs->trans(
"Code");
889 if ($fieldlist[$field] ==
'label') {
890 $valuetoshow = $langs->trans(
"Label");
892 if ($fieldlist[$field] ==
'type_template') {
893 $valuetoshow = $langs->trans(
"TypeOfTemplate");
896 if (in_array($fieldlist[$field], array(
'private',
'private',
'defaultfortype'))) {
900 if ($fieldlist[$field] ==
'topic') {
903 if ($fieldlist[$field] ==
'joinfiles') {
906 if ($fieldlist[$field] ==
'content') {
909 if ($fieldlist[$field] ==
'content_lines') {
912 if ($valuetoshow !=
'') {
913 print
'<th class="'.$css.
'">';
914 if (!empty($tabhelp[25][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[25][$value])) {
915 print
'<a href="'.$tabhelp[25][$value].
'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
916 } elseif (!empty($tabhelp[25][$value])) {
917 if (in_array($value, array(
'topic'))) {
918 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2, $value);
920 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2);
932 $tmpaction =
'create';
934 'fieldlist' => $fieldlist,
935 'tabname' => $tabname[25]
937 $reshook = $hookmanager->executeHooks(
'createEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
938 $error = $hookmanager->error;
939 $errors = $hookmanager->errors;
943 print
'<tr class="oddeven">';
945 if (empty($reshook)) {
946 if ($action ==
'edit') {
947 fieldList($fieldlist, $obj, $tabname[25],
'hide');
949 fieldList($fieldlist, $obj, $tabname[25],
'add');
953 print
'<td class="right">';
957 print
'<tr class="oddeven nodrag nodrop nohover"><td colspan="9" style="padding-left: 20px; padding-right: 20px;">';
960 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
962 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content',
'content_lines');
964 foreach ($fieldsforcontent as $tmpfieldlist) {
965 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
967 if ($tmpfieldlist ==
'topic') {
968 print
'<span class="bold minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
970 if ($tmpfieldlist ==
'email_from') {
971 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
973 if ($tmpfieldlist ==
'joinfiles') {
974 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span>';
976 if ($tmpfieldlist ==
'content') {
977 print
'<span class="minwidth150 inline-block margintoponly">'.$form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
979 if ($tmpfieldlist ==
'content_lines') {
980 print
'<span class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</span><br>';
984 if ($tmpfieldlist ==
'topic') {
985 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'">';
986 } elseif ($tmpfieldlist ==
'email_from') {
987 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'').
'" spellcheck="false">';
988 } elseif ($tmpfieldlist ==
'joinfiles') {
989 print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, false, 0, 1);
991 $okforextended =
true;
993 $okforextended =
false;
995 $doleditor =
new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
''),
'', 400,
'dolibarr_mailings',
'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'90%');
996 print $doleditor->Create(1);
1006 if ($action !=
'edit') {
1008 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'"> ';
1009 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
1016 print
'<br><br><br>';
1020print
'<div class="div-table-responsive-no-min">';
1021print
'<table class="noborder centpercent" id="table_list_of_c_email_templates">';
1035print
'<tr class="liste_titre" id="Title line with search boxes">';
1037if (
$conf->main_checkbox_left_column) {
1038 print
'<td class="liste_titre center" width="64">';
1039 $searchpicto = $form->showFilterButtons();
1043foreach ($fieldlist as $field => $value) {
1044 if ($value ==
'module') {
1045 print
'<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).
'" spellcheck="false"></td>';
1046 } elseif ($value ==
'label') {
1047 print
'<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).
'" spellcheck="false"></td>';
1048 } elseif ($value ==
'lang') {
1049 print
'<td class="liste_titre">';
1050 print $formadmin->select_language($search_lang,
'search_lang', 0, array(), 1, 0, 0,
'maxwidth100');
1052 } elseif ($value ==
'fk_user') {
1053 print
'<td class="liste_titre">';
1054 print $form->select_dolusers($search_fk_user,
'search_fk_user', 1,
null, 0, ($user->admin ?
'' :
'hierarchyme'), array(),
'0', 0, 0,
'', 0,
'',
'maxwidth100', 1);
1056 } elseif ($value ==
'topic') {
1057 print
'<td class="liste_titre"><input type="text" class="maxwidth150" name="search_topic" value="'.dol_escape_htmltag($search_topic).
'" spellcheck="false"></td>';
1058 } elseif ($value ==
'type_template') {
1059 print
'<td class="liste_titre center">';
1061 print $form->selectarray(
'search_type_template', $elementList, $search_type_template, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125', 1,
'', 0, 1);
1063 } elseif (!in_array($value, array(
'content',
'content_lines'))) {
1064 print
'<td class="liste_titre"></td>';
1074if (!empty($arrayfields[
't.tms'][
'checked'])) {
1077if (!empty($arrayfields[
't.datec'][
'checked'])) {
1081if (!
$conf->main_checkbox_left_column) {
1082 print
'<td class="liste_titre center" width="64">';
1083 $searchpicto = $form->showFilterButtons();
1090print
'<tr class="liste_titre" id="Title of lines">';
1092if (
$conf->main_checkbox_left_column) {
1095array_push($fieldlist,
"tms",
"datec");
1096foreach ($fieldlist as $field => $value) {
1109 $valuetoshow = ucfirst($fieldlist[$field]);
1110 $valuetoshow = $langs->trans($valuetoshow);
1111 if ($fieldlist[$field] ==
'module') {
1112 $css =
'tdoverflowmax100';
1114 if ($fieldlist[$field] ==
'fk_user') {
1115 $valuetoshow = $langs->trans(
"Owner");
1117 if ($fieldlist[$field] ==
'lang') {
1118 $valuetoshow = $langs->trans(
"Language");
1120 if ($fieldlist[$field] ==
'type') {
1121 $valuetoshow = $langs->trans(
"Type");
1123 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
1124 $valuetoshow = $langs->trans(
"Label");
1126 if ($fieldlist[$field] ==
'type_template') {
1128 $valuetoshow = $langs->trans(
"TypeOfTemplate");
1130 if ($fieldlist[$field] ==
'private') {
1133 if ($fieldlist[$field] ==
'position') {
1136 if ($fieldlist[$field] ==
'tms') {
1137 $valuetoshow =
'Modif. date';
1139 if ($fieldlist[$field] ==
'datec') {
1140 $valuetoshow =
'Date creation';
1143 if ($fieldlist[$field] ==
'joinfiles') {
1144 $valuetoshow = $langs->trans(
"FilesAttachedToEmail");
1148 if ($fieldlist[$field] ==
'content') {
1149 $valuetoshow = $langs->trans(
"Content");
1152 if ($fieldlist[$field] ==
'content_lines') {
1153 $valuetoshow = $langs->trans(
"ContentForLines");
1156 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1159 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1165 if (!empty($tabhelp[25][$value])) {
1166 if (in_array($value, array(
'topic'))) {
1167 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'tooltip'.$value, $forcenowrap);
1169 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1,
'help',
'', 0, 2,
'', $forcenowrap);
1172 $sortfieldtouse = ($sortable ? $fieldlist[$field] :
'');
1173 if ($sortfieldtouse ==
'type_template') {
1174 $sortfieldtouse .=
',lang,position,label';
1176 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], $sortfieldtouse, ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder, $css.
' ');
1180print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
1182if (!
$conf->main_checkbox_left_column) {
1191 $obj =
$db->fetch_object($resql);
1194 if (($action ==
'edit' || $action ==
'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1196 print
'<tr class="nohover oddeven noborderbottom" id="rowid-'.$obj->rowid.
'" name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'">';
1198 $tmpaction =
'edit';
1199 if ($action ==
'edit') {
1201 $fieldlist = explode(
',', $tabfield[25]);
1202 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1204 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1206 $reshook = $hookmanager->executeHooks(
'editEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1207 $error = $hookmanager->error;
1208 $errors = $hookmanager->errors;
1213 if (
$conf->main_checkbox_left_column) {
1214 print
'<td class="center">';
1219 if (empty($reshook)) {
1220 $colspan +=
fieldList($fieldlist, $obj, $tabname[25], $action);
1223 if (!
$conf->main_checkbox_left_column) {
1224 print
'<td class="center">';
1230 print
'<tr class="oddeven nohover" id="tr-aaa-'.$rowid.
'">';
1231 if (
$conf->main_checkbox_left_column) {
1232 print
'<td class="center"></td>';
1234 print
'<td colspan="'.($colspan - 1).
'" class="" style="padding-left: 20px; padding-right: 20px;">';
1236 $fieldsforcontent = array(
'topic',
'email_from',
'joinfiles',
'content');
1238 $fieldsforcontent[] =
'content_lines';
1241 $parameters = array(
'fieldsforcontent' => &$fieldsforcontent,
'tabname' => $tabname[25]);
1242 $hookmanager->executeHooks(
'editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction);
1244 print
'<div class="lineformailtemplatefield centpercent">';
1245 foreach ($fieldsforcontent as $tmpfieldlist) {
1248 $valuetoshow = $obj->$tmpfieldlist;
1253 print
'<div class="inline-block lineformailtemplatefield paddingtop paddingbottom centpercent">';
1255 if ($tmpfieldlist ==
'topic') {
1256 print
'<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1257 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
'>';
1260 if ($tmpfieldlist ==
'email_from') {
1261 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"MailFrom"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1262 print
'<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'"'.($action !=
'edit' ?
' disabled' :
'').
' spellcheck="false">';
1265 if ($tmpfieldlist ==
'joinfiles') {
1266 print
'<div class="minwidth150 inline-block">'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</div> ';
1267 print $form->selectyesno($tmpfieldlist.
'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist :
'0'), 1, ($action !=
'edit'), 0, 1);
1271 if ($tmpfieldlist ==
'content') {
1272 print $form->textwithpicto($langs->trans(
"Content"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1273 $okforextended =
true;
1275 $okforextended =
false;
1277 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 450,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%', ($action !=
'edit' ? 1 : 0));
1278 print $doleditor->Create(1);
1280 if ($tmpfieldlist ==
'content_lines') {
1282 print $form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[25][$tmpfieldlist], 1,
'help',
'margintoponly', 0, 2, $tmpfieldlist).
'<br>';
1283 $okforextended =
true;
1285 $okforextended =
false;
1287 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 140,
'dolibarr_mailings',
'In',
false, $acceptlocallinktomedia, $okforextended, ROWS_6,
'80%');
1288 print $doleditor->Create(1);
1294 print
'<center><input type="hidden" name="page" value="'.$page.
'">';
1295 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
1296 if ($action ==
'edit') {
1297 print
'<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans(
"Save").
'">';
1299 print
'<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
1303 if (!
$conf->main_checkbox_left_column) {
1304 print
'<td class="center"></td>';
1313 $tempmodulekey = $obj->module;
1320 $keyforobj =
'type_template';
1321 if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1326 if (! (
int)
dol_eval((
string) $obj->enabled, 1, 1,
'1')) {
1337 if (!$user->admin && $obj->fk_user != $user->id) {
1343 $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) :
'');
1348 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
1351 if (
$conf->main_checkbox_left_column) {
1352 print
'<td class="center nowraponall" width="64">';
1353 if ($canbemodified) {
1354 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
1356 print
'<a class="reposition editfielda" href="'.$url.
'&action=preview&token='.newToken().
'">'.
img_view().
'</a>';
1359 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.newToken().$param.
'">'.
img_delete().
'</a>';
1364 $tmpaction =
'view';
1365 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[25]);
1366 $reshook = $hookmanager->executeHooks(
'viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
1368 $error = $hookmanager->error;
1369 $errors = $hookmanager->errors;
1371 if (empty($reshook)) {
1372 foreach ($fieldlist as $field => $value) {
1373 if (in_array($fieldlist[$field], array(
'content',
'content_lines'))) {
1380 $tmpvar = $fieldlist[$field];
1381 $valuetoshow = $obj->$tmpvar;
1382 if ($value ==
'label' || $value ==
'topic') {
1383 if ($langs->trans($valuetoshow) != $valuetoshow) {
1384 $valuetoshow = $langs->trans($valuetoshow);
1388 if ($value ==
'label') {
1389 $class .=
' tdoverflowmax200';
1391 if ($value ==
'topic') {
1392 $class .=
' tdoverflowmax200 small';
1394 if ($value ==
'type_template') {
1395 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1396 $css =
"center tdoverflowmax150";
1398 if ($value ==
'lang' && $valuetoshow) {
1399 $valuetoshow = $valuetoshow.
' - '.$langs->trans(
"Language_".$valuetoshow);
1400 $class .=
' tdoverflowmax100';
1402 if ($value ==
'fk_user') {
1403 if ($valuetoshow > 0) {
1405 $fuser->fetch($valuetoshow);
1406 $valuetoshow = $fuser->getNomUrl(-1);
1408 if ($obj->private) {
1409 $valuetoshow =
img_picto($langs->transnoentitiesnoconv(
"Private"),
'lock',
'class="pictofixedwidth"').$valuetoshow;
1412 $class .=
' tdoverflowmax100';
1415 if ($value ==
'private') {
1418 $valuetoshow =
yn($valuetoshow);
1423 if ($value ==
'position') {
1426 if (in_array($value, array(
'joinfiles',
'defaultfortype'))) {
1430 $valuetoshow =
'<input type="checkbox" checked="checked" disabled>';
1439 if ($value ==
'tms' && empty($arrayfields[
't'.$value][
'checked'])) {
1442 if ($value ==
'datec' && empty($arrayfields[
't.'.$value][
'checked'])) {
1448 print
'<!-- '.$fieldlist[$field].
' -->';
1449 print
'<td class="'.$class.
'"';
1450 if (in_array($value, array(
'code',
'label',
'topic'))) {
1451 print
' title="'.dol_escape_htmltag($valuetoshow).
'"';
1461 print
'<td class="center nowrap">';
1462 if ($canbedisabled) {
1463 print
'<a class="reposition" href="'.$url.
'&action='.$acts[$obj->active].
'&token='.newToken().
'">'.$actl[$obj->active].
'</a>';
1465 print
'<span class="opacitymedium">'.$actl[$obj->active].
'</span>';
1470 if (!
$conf->main_checkbox_left_column) {
1471 print
'<td class="center nowraponall" width="64">';
1472 if ($canbemodified) {
1473 print
'<a class="reposition editfielda" href="'.$url.
'&action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
1476 print
'<a class="reposition marginleftonly" href="'.$url.
'&action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
1491if ($nbqualified == 0) {
1493 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1499if ($action !=
'create') {
1503if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
1524 global $langs, $user,
$db;
1526 global $elementList;
1529 $nboffieldsprinted = 0;
1531 foreach ($fieldlist as $value) {
1533 if ($value ==
'module') {
1535 $nboffieldsprinted++;
1536 } elseif ($value ==
'fk_user') {
1538 if ($user->admin &&
$context !=
'preview') {
1539 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');
1542 print $user->getNomUrl(-1);
1543 $forcedvalue = $user->id;
1545 if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1547 $fuser->fetch($obj->$value);
1548 print $fuser->getNomUrl(-1);
1549 $forcedvalue = $fuser->id;
1551 $forcedvalue = $obj->$value;
1555 print
'<input type="hidden" value="'.$forcedvalue.
'" name="'.$keyname.
'">';
1558 $nboffieldsprinted++;
1559 } elseif ($value ==
'lang') {
1562 $selectedlang = GETPOSTISSET(
'langcode') ?
GETPOST(
'langcode',
'aZ09') : $langs->defaultlang;
1564 $selectedlang = $obj->lang;
1566 print $formadmin->select_language($selectedlang,
'langcode', 0, array(), $langs->trans(
"Language"), 0, 0,
'maxwidth100');
1568 if (!empty($obj->lang)) {
1569 print $obj->lang.
' - '.$langs->trans(
'Language_'.$obj->lang);
1572 if ($keyname ==
'lang') {
1573 $keyname =
'langcode';
1575 print
'<input type="hidden" value="'.(empty($obj->lang) ?
'' : $obj->lang).
'" name="'.$keyname.
'">';
1578 $nboffieldsprinted++;
1579 } elseif ($value ==
'type_template') {
1581 print
'<td class="center">';
1582 if ((
$context ==
'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) ||
$context ==
'preview') {
1584 print
'<input type="hidden" name="type_template" value="'.$obj->type_template.
'">';
1585 print $obj->type_template;
1587 print $form->selectarray(
'type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 maxwidth125', 1,
'', 0, 1);
1590 $nboffieldsprinted++;
1591 } elseif (
$context ==
'add' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1593 } elseif (
$context ==
'edit' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1595 $nboffieldsprinted++;
1596 } elseif (
$context ==
'preview' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1598 $nboffieldsprinted++;
1599 } elseif (
$context ==
'hide' && in_array($value, array(
'topic',
'joinfiles',
'content',
'content_lines'))) {
1605 if ($value ==
'code') {
1606 $class =
'maxwidth100';
1608 if ($value ==
'label') {
1609 $class =
'maxwidth200';
1611 if ($value ==
'private') {
1612 $class =
'maxwidth50';
1613 $classtd =
'center';
1615 if ($value ==
'position') {
1616 $class =
'maxwidth50 center';
1617 $classtd =
'center';
1619 if ($value ==
'topic') {
1620 $class =
'quatrevingtpercent';
1622 if ($value ==
'defaultfortype') {
1623 $class =
'width25 center';
1624 $classtd =
'center';
1627 print
'<td'.($classtd ?
' class="'.$classtd.
'"' :
'').
'>';
1628 if (in_array($value, array(
'defaultfortype',
'private')) &&
$context !=
'preview') {
1629 if (empty($user->admin)) {
1631 print $form->selectyesno($value, GETPOSTISSET($value) ?
GETPOSTINT($value) : ((
$context !=
'add' && isset($obj->$value)) ? $obj->$value :
'1'), 1,
false, 0, 1);
1634 print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value :
''), 1,
false, 0, 1);
1637 print
'<input type="text" '.$size.
'class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->$value) ? $obj->$value :
'').
'" name="'. $value .
'"'.(
$context ==
'preview' ?
' disabled' :
'').
' spellcheck="false">';
1640 $nboffieldsprinted++;
1644 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.
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.
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.
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.
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.
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...
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
buildzip.php
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.