36 require
'../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
46 $langs->loadLangs(array(
"errors",
"admin",
"mails",
"languages"));
48 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
49 $confirm =
GETPOST(
'confirm',
'alpha');
52 $rowid =
GETPOST(
'rowid',
'alpha');
53 $search_label =
GETPOST(
'search_label',
'alphanohtml');
54 $search_type_template =
GETPOST(
'search_type_template',
'alpha');
55 $search_lang =
GETPOST(
'search_lang',
'alpha');
56 $search_fk_user =
GETPOST(
'search_fk_user',
'intcomma');
57 $search_topic =
GETPOST(
'search_topic',
'alpha');
63 $acts[0] =
"activate";
65 $actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off');
66 $actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on');
68 $listoffset =
GETPOST(
'listoffset',
'alpha');
69 $listlimit =
GETPOST(
'listlimit',
'alpha') > 0 ?
GETPOST(
'listlimit',
'alpha') : 1000;
71 $sortfield =
GETPOST(
"sortfield",
'alpha');
72 $sortorder =
GETPOST(
"sortorder",
'alpha');
74 if (empty($page) || $page == -1) { $page = 0; }
75 $offset = $listlimit * $page;
76 $pageprev = $page - 1;
77 $pagenext = $page + 1;
79 if (empty($sortfield)) $sortfield =
'type_template, lang, position, label';
80 if (empty($sortorder)) $sortorder =
'ASC';
83 $hookmanager->initHooks(array(
'emailtemplates'));
87 $tabname[25] = MAIN_DB_PREFIX.
"c_email_templates";
91 $tabfield[25] =
"label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
92 if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25] .=
',content_lines';
95 $tabfieldvalue = array();
96 $tabfieldvalue[25] =
"label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
97 if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25] .=
',content_lines';
100 $tabfieldinsert = array();
101 $tabfieldinsert[25] =
"label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
102 if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25] .=
',content_lines';
103 $tabfieldinsert[25] .=
',entity';
111 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
113 if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
116 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
117 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
118 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
119 foreach ($tmp as $key => $val)
121 $helpsubstit .= $key.
' -> '.$val.
'<br>';
122 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
126 $tmp[
'__(AnyTranslationKey)__'] =
'Translation';
127 $helpsubstit = $langs->trans(
"AvailableVariables").
':<br>';
128 $helpsubstitforlines = $langs->trans(
"AvailableVariables").
':<br>';
129 foreach ($tmp as $key => $val)
131 $helpsubstit .= $key.
' -> '.$val.
'<br>';
134 foreach ($tmp as $key => $val)
136 $helpsubstitforlines .= $key.
' -> '.$val.
'<br>';
142 $tabhelp[25] = array(
143 'topic'=>$helpsubstit,
144 'joinfiles'=>$langs->trans(
'AttachMainDocByDefault'),
145 'content'=>$helpsubstit,
146 'content_lines'=>$helpsubstitforlines,
147 'type_template'=>$langs->trans(
"TemplateForElement"),
148 'private'=>$langs->trans(
"TemplateIsVisibleByOwnerOnly"),
149 'position'=>$langs->trans(
"PositionIntoComboList")
153 $tabfieldcheck = array();
154 $tabfieldcheck[25] = array();
157 $elementList = array();
160 $elementList = array();
162 $elementList[
'all'] =
'-- '.dol_escape_htmltag($langs->trans(
"All")).
' --';
163 $elementList[
'none'] =
'-- '.dol_escape_htmltag($langs->trans(
"None")).
' --';
164 $elementList[
'user'] =
img_picto(
'',
'user',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToUser'));
165 if ($conf->adherent->enabled && $user->rights->adherent->lire) {
166 $elementList[
'member'] =
img_picto(
'',
'object_member',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToMember'));
168 if ($conf->recruitment->enabled && $user->rights->recruitment->recruitmentjobposition->read) {
169 $elementList[
'recruitmentcandidature_send'] =
img_picto(
'',
'recruitmentcandidature',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'RecruitmentCandidatures'));
171 if ($conf->societe->enabled && $user->rights->societe->lire) {
172 $elementList[
'thirdparty'] =
img_picto(
'',
'company',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToThirdparty'));
174 if ($conf->projet->enabled) {
175 $elementList[
'project'] =
img_picto(
'',
'project',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToProject'));
177 if ($conf->propal->enabled && $user->rights->propal->lire) {
178 $elementList[
'propal_send'] =
img_picto(
'',
'propal',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendProposal'));
180 if ($conf->commande->enabled && $user->rights->commande->lire) {
181 $elementList[
'order_send'] =
img_picto(
'',
'order',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendOrder'));
183 if ($conf->facture->enabled && $user->rights->facture->lire) {
184 $elementList[
'facture_send'] =
img_picto(
'',
'bill',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendInvoice'));
186 if ($conf->expedition->enabled) {
187 $elementList[
'shipping_send'] =
img_picto(
'',
'dolly',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendShipment'));
189 if ($conf->reception->enabled) {
190 $elementList[
'reception_send'] =
img_picto(
'',
'dolly',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendReception'));
192 if ($conf->ficheinter->enabled) {
193 $elementList[
'fichinter_send'] =
img_picto(
'',
'intervention',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendIntervention'));
195 if ($conf->supplier_proposal->enabled) {
196 $elementList[
'supplier_proposal_send'] =
img_picto(
'',
'propal',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierRequestForQuotation'));
198 if (($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_order->enabled && $user->rights->supplier_order->lire)) {
199 $elementList[
'order_supplier_send'] =
img_picto(
'',
'order',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierOrder'));
201 if (($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_invoice->enabled && $user->rights->supplier_invoice->lire)) {
202 $elementList[
'invoice_supplier_send'] =
img_picto(
'',
'bill',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendSupplierInvoice'));
204 if ($conf->contrat->enabled && $user->rights->contrat->lire) {
205 $elementList[
'contract'] =
img_picto(
'',
'contract',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendContract'));
207 if ($conf->ticket->enabled && $user->rights->ticket->read) {
208 $elementList[
'ticket_send'] =
img_picto(
'',
'ticket',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToTicket'));
210 if ($conf->agenda->enabled) {
211 $elementList[
'actioncomm_send'] =
img_picto(
'',
'action',
'class="paddingright"').dol_escape_htmltag($langs->trans(
'MailToSendEventPush'));
214 $parameters = array(
'elementList'=>$elementList);
215 $reshook = $hookmanager->executeHooks(
'emailElementlist', $parameters);
217 foreach ($hookmanager->resArray as $item => $value) {
218 $elementList[$item] = $value;
231 if (
GETPOST(
'cancel',
'alpha')) {
235 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
237 $parameters = array();
238 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
243 if (empty($reshook)) {
245 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
248 $search_type_template =
'';
250 $search_fk_user =
'';
253 $search_array_options = array();
257 if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
258 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
259 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
260 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
261 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
265 foreach ($listfield as $f => $value) {
267 if ($value ==
'joinfiles')
continue;
268 if ($value ==
'content')
continue;
269 if ($value ==
'content_lines')
continue;
272 if (
GETPOST(
'actionmodify',
'alpha') && $value ==
'topic') $_POST[
'topic'] = $_POST[
'topic-'.$rowid];
274 if ((!
GETPOSTISSET($value) ||
GETPOST($value) ==
'' ||
GETPOST($value) ==
'-1') && $value !=
'lang' && $value !=
'fk_user' && $value !=
'position')
277 $fieldnamekey = $listfield[$f];
279 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) $fieldnamekey =
'Code';
280 if ($fieldnamekey ==
'code') $fieldnamekey =
'Code';
281 if ($fieldnamekey ==
'note') $fieldnamekey =
'Note';
282 if ($fieldnamekey ==
'type_template') $fieldnamekey =
'TypeOfTemplate';
283 if ($fieldnamekey ==
'fk_user') $fieldnamekey =
'Owner';
284 if ($fieldnamekey ==
'private') $fieldnamekey =
'Private';
285 if ($fieldnamekey ==
'position') $fieldnamekey =
'Position';
286 if ($fieldnamekey ==
'topic') $fieldnamekey =
'Topic';
288 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null,
'errors');
293 if ($ok &&
GETPOST(
'actionadd'))
296 $sql =
"INSERT INTO ".$tabname[$id].
" (";
298 $sql .= $tabfieldinsert[$id];
304 foreach ($listfieldinsert as $f => $value)
306 $keycode = $listfieldvalue[$i];
307 if ($value ==
'lang') $keycode =
'langcode';
308 if (empty($keycode)) $keycode = $value;
311 if ($value ==
'entity') $_POST[$keycode] = $conf->entity;
312 if ($value ==
'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] =
'';
313 if ($value ==
'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] =
'0';
314 if ($value ==
'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] =
'1';
317 if ($i) $sql .=
", ";
318 if (
GETPOST($keycode) ==
'' && $keycode !=
'langcode') $sql .=
"null";
319 elseif (
GETPOST($keycode) ==
'0' && $keycode ==
'langcode') $sql .= "''";
320 elseif ($keycode == 'fk_user') {
322 $sql .=
" ".((int) $user->id);
324 $sql .=
" ".((int)
GETPOST($keycode,
'int'));
326 } elseif ($keycode ==
'content') {
327 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
328 } elseif (in_array($keycode, array(
'joinfiles',
'private',
'position'))) {
329 $sql .= (int)
GETPOST($keycode,
'int');
331 $sql .=
"'".$db->escape(
GETPOST($keycode,
'nohtml')).
"'";
338 $result = $db->query($sql);
342 $_POST = array(
'id'=>$id);
344 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
345 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"), null,
'errors');
353 if ($ok &&
GETPOST(
'actionmodify'))
358 $sql =
"UPDATE ".$tabname[$id].
" SET ";
361 foreach ($listfieldmodify as $field)
363 $keycode = $listfieldvalue[$i];
364 if ($field ==
'lang') $keycode =
'langcode';
365 if (empty($keycode)) $keycode = $field;
368 if ($field ==
'fk_user' && !($_POST[
'fk_user'] > 0)) $_POST[
'fk_user'] =
'';
369 if ($field ==
'topic') $_POST[
'topic'] = $_POST[
'topic-'.$rowid];
370 if ($field ==
'joinfiles') $_POST[
'joinfiles'] = $_POST[
'joinfiles-'.$rowid];
371 if ($field ==
'content') $_POST[
'content'] = $_POST[
'content-'.$rowid];
372 if ($field ==
'content_lines') $_POST[
'content_lines'] = $_POST[
'content_lines-'.$rowid];
373 if ($field ==
'entity') $_POST[$keycode] = $conf->entity;
375 if ($i) $sql .=
", ";
378 if (
GETPOST($keycode) ==
'' || ($keycode !=
'langcode' && $keycode !=
'position' && $keycode !=
'private' && !
GETPOST($keycode))) $sql .=
"null";
379 elseif (
GETPOST($keycode) ==
'0' && $keycode ==
'langcode') $sql .= "''";
380 elseif ($keycode == 'fk_user') {
382 $sql .=
" ".((int) $user->id);
384 $sql .=
" ".((int)
GETPOST($keycode,
'int'));
386 } elseif ($keycode ==
'content') {
387 $sql .=
"'".$db->escape(
GETPOST($keycode,
'restricthtml')).
"'";
388 } elseif (in_array($keycode, array(
'joinfiles',
'private',
'position'))) {
389 $sql .= (int)
GETPOST($keycode,
'int');
391 $sql .=
"'".$db->escape(
GETPOST($keycode,
'nohtml')).
"'";
397 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
399 $sql .=
" AND fk_user = ".((int) $user->id);
404 $resql = $db->query($sql);
414 if ($action ==
'confirm_delete' && $confirm ==
'yes')
418 $sql =
"DELETE from ".$tabname[$id].
" WHERE ".$rowidcol.
"=".((int) $rowid);
420 $sql .=
" AND fk_user = ".((int) $user->id);
423 $result = $db->query($sql);
426 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS')
428 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"), null,
'errors');
436 if ($action == $acts[0])
440 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE ".$rowidcol.
"=".((int) $rowid);
442 $result = $db->query($sql);
450 if ($action == $acts[1])
454 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE ".$rowidcol.
"=".((int) $rowid);
456 $result = $db->query($sql);
469 $form =
new Form($db);
473 $title = $langs->trans(
"EMailsSetup");
478 $titlepicto =
'title_setup';
487 if ($action ==
'delete')
489 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?'.($page ?
'page='.$page.
'&' :
'').
'sortfield='.$sortfield.
'&sortorder='.$sortorder.
'&rowid='.$rowid.
'&code='.$code.
'&id='.$id, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_delete',
'', 0, 1);
493 $sql =
"SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active";
494 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_email_templates";
495 $sql .=
" WHERE entity IN (".getEntity(
'email_template').
")";
498 $sql .=
" AND (private = 0 OR (private = 1 AND fk_user = ".$user->id.
"))";
499 $sql .=
" AND (active = 1 OR fk_user = ".$user->id.
")";
501 if (empty($conf->global->MAIN_MULTILANGS))
503 $sql .=
" AND (lang = '".$db->escape($langs->defaultlang).
"' OR lang IS NULL OR lang = '')";
505 if ($search_label) $sql .=
natural_search(
'label', $search_label);
506 if ($search_type_template !=
'' && $search_type_template !=
'-1') $sql .=
natural_search(
'type_template', $search_type_template);
508 if ($search_fk_user !=
'' && $search_fk_user !=
'-1') $sql .=
natural_search(
'fk_user', $search_fk_user, 2);
509 if ($search_topic) $sql .=
natural_search(
'topic', $search_topic);
511 if ($sortfield ==
'country') $sortfield =
'country_code';
512 $sql .= $db->order($sortfield, $sortorder);
513 $sql .= $db->plimit($listlimit + 1, $offset);
516 $fieldlist = explode(
',', $tabfield[$id]);
518 if ($action ==
'view') {
520 print '<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
521 print '<input type="hidden" name="token" value="'.newToken().
'">';
522 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
524 print '<div class="div-table-responsive-no-min">';
525 print '<table class="noborder centpercent">';
528 print '<tr class="liste_titre">';
529 foreach ($fieldlist as $field => $value)
533 $valuetoshow = ucfirst($fieldlist[$field]);
534 $valuetoshow = $langs->trans($valuetoshow);
536 if ($fieldlist[$field] ==
'fk_user') { $valuetoshow = $langs->trans(
"Owner"); }
537 if ($fieldlist[$field] ==
'lang') { $valuetoshow = (empty($conf->global->MAIN_MULTILANGS) ?
' ' : $langs->trans(
"Language")); }
538 if ($fieldlist[$field] ==
'type') { $valuetoshow = $langs->trans(
"Type"); }
539 if ($fieldlist[$field] ==
'code') { $valuetoshow = $langs->trans(
"Code"); }
540 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') { $valuetoshow = $langs->trans(
"Code"); }
541 if ($fieldlist[$field] ==
'type_template') { $valuetoshow = $langs->trans(
"TypeOfTemplate"); $align =
"center"; }
542 if ($fieldlist[$field] ==
'private') { $align =
'center'; }
543 if ($fieldlist[$field] ==
'position') { $align =
'center'; }
545 if ($fieldlist[$field] ==
'topic') { $valuetoshow =
''; }
546 if ($fieldlist[$field] ==
'joinfiles') { $valuetoshow =
''; }
547 if ($fieldlist[$field] ==
'content') { $valuetoshow =
''; }
548 if ($fieldlist[$field] ==
'content_lines') { $valuetoshow =
''; }
550 if ($valuetoshow !=
'')
552 print '<td class="'.$align.
'">';
553 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value]))
print '<a href="'.$tabhelp[$id][$value].
'" target="_blank">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
554 elseif (!empty($tabhelp[$id][$value]))
556 if (in_array($value, array(
'topic')))
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1,
'help',
'', 0, 2, $value);
557 else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1,
'help',
'', 0, 2);
558 }
else print $valuetoshow;
563 print '<input type="hidden" name="id" value="'.$id.
'">';
567 $obj =
new stdClass();
571 foreach ($fieldlist as $key => $val) {
577 $tmpaction =
'create';
579 'fieldlist' => $fieldlist,
580 'tabname' => $tabname[$id]
582 $reshook = $hookmanager->executeHooks(
'createEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
583 $error = $hookmanager->error;
584 $errors = $hookmanager->errors;
588 print '<tr class="oddeven">';
592 if ($action ==
'edit') {
593 fieldList($fieldlist, $obj, $tabname[$id],
'hide');
595 fieldList($fieldlist, $obj, $tabname[$id],
'add');
599 print '<td class="right">';
604 $fieldsforcontent = array(
'topic',
'joinfiles',
'content');
605 if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array(
'topic',
'joinfiles',
'content',
'content_lines'); }
606 foreach ($fieldsforcontent as $tmpfieldlist)
608 print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
611 if ($tmpfieldlist ==
'topic')
613 print '<strong>'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</strong> ';
615 if ($tmpfieldlist ==
'joinfiles')
617 print '<strong>'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</strong> ';
619 if ($tmpfieldlist ==
'content')
620 print $form->textwithpicto($langs->trans(
"Content"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'<br>';
621 if ($tmpfieldlist ==
'content_lines')
622 print $form->textwithpicto($langs->trans(
"ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'<br>';
625 if ($tmpfieldlist ==
'topic') {
626 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'">';
627 } elseif ($tmpfieldlist ==
'joinfiles') {
628 print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.
'" value="'.(isset($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'1').
'">';
631 $okforextended =
true;
632 if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
633 $okforextended =
false;
634 $doleditor =
new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 180,
'dolibarr_mailings',
'In', 0,
false, $okforextended, ROWS_4,
'90%');
635 print $doleditor->Create(1);
638 if ($tmpfieldlist ==
'topic') {
639 print '<td class="center" rowspan="'.(count($fieldsforcontent)).
'">';
640 if ($action !=
'edit') {
641 print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans(
"Add").
'">';
655 print '<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
656 print '<input type="hidden" name="token" value="'.newToken().
'">';
657 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
659 print '<div class="div-table-responsive-no-min">';
660 print '<table class="noborder centpercent">';
664 $resql = $db->query($sql);
667 $num = $db->num_rows(
$resql);
671 if ($search_label) $param .=
'&search_label='.urlencode($search_label);
672 if ($search_lang > 0) $param .=
'&search_lang='.urlencode($search_lang);
673 if ($search_type_template !=
'-1') $param .=
'&search_type_template='.urlencode($search_type_template);
674 if ($search_fk_user > 0) $param .=
'&search_fk_user='.urlencode($search_fk_user);
675 if ($search_topic) $param .=
'&search_topic='.urlencode($search_topic);
677 $paramwithsearch = $param;
678 if ($sortorder) $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
679 if ($sortfield) $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
680 if (
GETPOST(
'from',
'alpha')) $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
683 if ($num > $listlimit)
685 print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).
'">';
686 print_fleche_navigation($page,
$_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
692 print '<tr class="liste_titre">';
694 foreach ($fieldlist as $field => $value)
696 if ($value ==
'label') {
697 print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).
'"></td>';
698 } elseif ($value ==
'lang') {
699 print '<td class="liste_titre">';
700 print $formadmin->select_language($search_lang,
'search_lang', 0, null, 1, 0, 0,
'maxwidth150');
702 } elseif ($value ==
'fk_user') {
703 print '<td class="liste_titre">';
704 print $form->select_dolusers($search_fk_user,
'search_fk_user', 1, null, 0, ($user->admin ?
'' :
'hierarchyme'), null, 0, 0, 1,
'', 0,
'',
'maxwidth150');
706 } elseif ($value ==
'topic') {
707 print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).
'"></td>';
708 } elseif ($value ==
'type_template') {
709 print '<td class="liste_titre center">';
710 print $form->selectarray(
'search_type_template', $elementList, $search_type_template, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200', 1,
'', 0, 1);
712 } elseif (!in_array($value, array(
'content',
'content_lines'))) {
713 print '<td class="liste_titre"></td>';
717 if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
print '<td class="liste_titre"></td>';
720 print '<td class="liste_titre right" width="64">';
721 $searchpicto = $form->showFilterButtons();
727 print '<tr class="liste_titre">';
728 foreach ($fieldlist as $field => $value)
742 $valuetoshow = ucfirst($fieldlist[$field]);
743 $valuetoshow = $langs->trans($valuetoshow);
744 if ($fieldlist[$field] ==
'fk_user') { $valuetoshow = $langs->trans(
"Owner"); }
745 if ($fieldlist[$field] ==
'lang') { $valuetoshow = $langs->trans(
"Language"); }
746 if ($fieldlist[$field] ==
'type') { $valuetoshow = $langs->trans(
"Type"); }
747 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') { $valuetoshow = $langs->trans(
"Code"); }
748 if ($fieldlist[$field] ==
'type_template') { $valuetoshow = $langs->trans(
"TypeOfTemplate"); }
749 if ($fieldlist[$field] ==
'private') { $align =
'center'; }
750 if ($fieldlist[$field] ==
'position') { $align =
'center'; }
752 if ($fieldlist[$field] ==
'joinfiles') { $valuetoshow = $langs->trans(
"FilesAttachedToEmail"); $align =
'center'; $forcenowrap = 0; }
753 if ($fieldlist[$field] ==
'content') { $valuetoshow = $langs->trans(
"Content"); $showfield = 0; }
754 if ($fieldlist[$field] ==
'content_lines') { $valuetoshow = $langs->trans(
"ContentLines"); $showfield = 0; }
759 if (!empty($tabhelp[$id][$value]))
761 if (in_array($value, array(
'topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1,
'help',
'', 0, 2,
'tooltip'.$value, $forcenowrap);
762 else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1,
'help',
'', 0, 2,
'', $forcenowrap);
764 print getTitleFieldOfList($valuetoshow, 0,
$_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"align=".$align, $sortfield, $sortorder);
768 print getTitleFieldOfList($langs->trans(
"Status"), 0,
$_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'align="center"', $sortfield, $sortorder);
777 $obj = $db->fetch_object(
$resql);
779 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
781 print '<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
784 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
785 $reshook = $hookmanager->executeHooks(
'editEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
786 $error = $hookmanager->error; $errors = $hookmanager->errors;
789 if (empty($reshook))
fieldList($fieldlist, $obj, $tabname[$id],
'edit');
791 print '<td></td><td></td><td></td>';
792 print '<td class="center">';
793 print '<input type="hidden" name="page" value="'.$page.
'">';
794 print '<input type="hidden" name="rowid" value="'.$rowid.
'">';
795 print '<input type="submit" class="button buttongen" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
796 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
797 print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
800 $fieldsforcontent = array(
'topic',
'joinfiles',
'content');
801 if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
803 $fieldsforcontent = array(
'topic',
'joinfiles',
'content',
'content_lines');
805 foreach ($fieldsforcontent as $tmpfieldlist)
809 $valuetoshow = $obj->{$tmpfieldlist};
815 print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.
'-'.$rowid.
' ">';
816 print '<td colspan="8">';
817 if ($tmpfieldlist ==
'topic')
819 print '<strong>'.$form->textwithpicto($langs->trans(
"Topic"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</strong> ';
820 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'">';
822 if ($tmpfieldlist ==
'joinfiles')
824 print '<strong>'.$form->textwithpicto($langs->trans(
"FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'</strong> ';
825 print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.
'-'.$rowid.
'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
'').
'">';
827 if ($tmpfieldlist ==
'content')
829 print $form->textwithpicto($langs->trans(
"Content"), $tabhelp[$id][$tmpfieldlist], 1,
'help',
'', 0, 2, $tmpfieldlist).
'<br>';
830 $okforextended =
true;
831 if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended =
false;
832 $doleditor =
new DolEditor($tmpfieldlist.
'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} :
''),
'', 500,
'dolibarr_mailings',
'In', 0,
false, $okforextended, ROWS_6,
'90%');
833 print $doleditor->Create(1);
845 $tempmodulekey = $obj->module;
846 if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) {
852 $keyforobj =
'type_template';
853 if (!in_array($obj->$keyforobj, array_keys($elementList)))
865 print '<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
868 $parameters = array(
'var'=>$var,
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
869 $reshook = $hookmanager->executeHooks(
'viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction);
871 $error = $hookmanager->error; $errors = $hookmanager->errors;
875 foreach ($fieldlist as $field => $value)
877 if (in_array($fieldlist[$field], array(
'content',
'content_lines')))
continue;
881 $valuetoshow = $obj->{$fieldlist[$field]};
882 if ($value ==
'label' || $value ==
'topic') {
885 if ($value ==
'label') {
886 $class .=
' tdoverflowmax100';
891 if ($value ==
'type_template') {
892 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
895 if ($value ==
'lang' && $valuetoshow) {
896 $valuetoshow = $valuetoshow.
' - '.$langs->trans(
"Language_".$valuetoshow);
898 if ($value ==
'fk_user') {
899 if ($valuetoshow > 0)
901 $fuser =
new User($db);
902 $fuser->fetch($valuetoshow);
903 $valuetoshow = $fuser->getNomUrl(1);
906 if ($value ==
'private') {
908 if ($valuetoshow) $valuetoshow =
yn($valuetoshow);
909 else $valuetoshow =
'';
911 if ($value ==
'position') {
914 if ($value ==
'joinfiles') {
916 if ($valuetoshow) $valuetoshow = 1;
917 else $valuetoshow =
'';
919 if ($align) $class .=
' '.$align;
923 print '<!-- '.$fieldlist[$field].
' -->';
924 print '<td class="'.$class.
'">'.$valuetoshow.
'</td>';
930 $iserasable = 1; $canbedisabled = 1; $canbemodified = 1;
931 if (!$user->admin && $obj->fk_user != $user->id)
938 $url =
$_SERVER[
"PHP_SELF"].
'?'.($page ?
'page='.$page.
'&' :
'').
'sortfield='.$sortfield.
'&sortorder='.$sortorder.
'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code :
'')).
'&code='.(!empty($obj->code) ?urlencode($obj->code) :
'');
939 if ($param) $url .=
'&'.$param;
943 print '<td class="center nowrap">';
944 if ($canbedisabled)
print '<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
945 else print '<span class="opacitymedium">'.$actl[$obj->active].
'</span>';
949 print '<td class="center nowraponall" width="64">';
950 if ($canbemodified)
print '<a class="reposition editfielda" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
1019 function fieldList($fieldlist, $obj =
'', $tabname =
'', $context =
'')
1021 global $conf, $langs, $user, $db;
1023 global $elementList;
1027 foreach ($fieldlist as $field => $value)
1029 if ($fieldlist[$field] ==
'fk_user')
1033 print $form->select_dolusers($obj->{$fieldlist[$field]},
'fk_user', 1, null, 0, ($user->admin ?
'' :
'hierarchyme'), null, 0, 0, 1,
'', 0,
'',
'maxwidth200');
1035 if ($context ==
'add')
1037 print $user->getNomUrl(1);
1038 $forcedvalue = $user->id;
1040 if ($obj && !empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0)
1042 $fuser =
new User($db);
1043 $fuser->fetch($obj->{$fieldlist[$field]});
1044 print $fuser->getNomUrl(1);
1045 $forcedvalue = $fuser->id;
1047 $forcedvalue = $obj->{$fieldlist[$field]};
1050 $keyname = $fieldlist[$field];
1051 print '<input type="hidden" value="'.$forcedvalue.
'" name="'.$keyname.
'">';
1054 } elseif ($fieldlist[$field] ==
'lang')
1057 if (!empty($conf->global->MAIN_MULTILANGS))
1059 $selectedlang =
GETPOSTISSET(
'langcode') ?
GETPOST(
'langcode',
'aZ09') : $langs->defaultlang;
1060 if ($context ==
'edit') $selectedlang = $obj->{$fieldlist[$field]};
1061 print $formadmin->select_language($selectedlang,
'langcode', 0, null, 1, 0, 0,
'maxwidth150');
1063 if (!empty($obj->{$fieldlist[$field]}))
1065 print $obj->{$fieldlist[$field]}.
' - '.$langs->trans(
'Language_'.$obj->{$fieldlist[$field]});
1067 $keyname = $fieldlist[$field];
1068 if ($keyname ==
'lang') $keyname =
'langcode';
1069 print '<input type="hidden" value="'.$obj->{$fieldlist[$field]}.
'" name="'.$keyname.
'">';
1074 elseif ($fieldlist[$field] ==
'type_template')
1076 print '<td class="center">';
1077 if ($context ==
'edit' && !empty($obj->{$fieldlist[$field]}) && !in_array($obj->{$fieldlist[$field]}, array_keys($elementList)))
1080 print '<input type="hidden" name="type_template" value="'.$obj->{$fieldlist[$field]}.
'">';
1081 print $obj->{$fieldlist[$field]};
1083 print $form->selectarray(
'type_template', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
''), 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200', 1,
'', 0, 1);
1086 } elseif ($context ==
'add' && in_array($fieldlist[$field], array(
'topic',
'joinfiles',
'content',
'content_lines'))) continue;
1087 elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1088 elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1090 $size =
''; $class =
''; $classtd =
'';
1091 if ($fieldlist[$field] ==
'code') $class =
'maxwidth100';
1092 if ($fieldlist[$field] ==
'label') $class =
'maxwidth200';
1093 if ($fieldlist[$field] ==
'private') { $class =
'maxwidth50'; $classtd =
'center'; }
1094 if ($fieldlist[$field] ==
'position') { $class =
'maxwidth50'; $classtd =
'center'; }
1095 if ($fieldlist[$field] ==
'libelle') $class =
'quatrevingtpercent';
1096 if ($fieldlist[$field] ==
'topic') $class =
'quatrevingtpercent';
1097 if ($fieldlist[$field] ==
'sortorder' || $fieldlist[$field] ==
'sens' || $fieldlist[$field] ==
'category_type') $size =
'size="2" ';
1099 print '<td'.($classtd ?
' class="'.$classtd.
'"' :
'').
'>';
1100 if ($fieldlist[$field] ==
'private')
1102 if (empty($user->admin))
1104 print $form->selectyesno($fieldlist[$field],
'1', 1);
1107 print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
''), 1);
1110 print '<input type="text" '.$size.
'class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
'').
'" name="'.$fieldlist[$field].
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
print_fleche_navigation($page, $file, $options= '', $nextpage=0, $betweenarrows= '', $afterarrows= '', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows= '')
Function to show navigation arrows into lists.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
fieldList($fieldlist, $obj= '', $tabname= '', $context= '')
Show fields in insert/edit mode.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...