32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
78 public $fromalsorobot;
138 public $witherrorsto;
153 public $withaiprompt;
158 public $withmaindocfile;
161 public $withfromreadonly;
162 public $withreplytoreadonly;
163 public $withtoreadonly;
164 public $withtoccreadonly;
165 public $witherrorstoreadonly;
166 public $withtocccreadonly;
167 public $withtopicreadonly;
168 public $withbodyreadonly;
169 public $withfilereadonly;
170 public $withdeliveryreceipt;
172 public $withdeliveryreceiptreadonly;
173 public $withfckeditor;
178 public $ckeditortoolbar;
180 public $substit = array();
181 public $substit_lines = array();
185 public $param = array();
187 public $withtouser = array();
188 public $withtoccuser = array();
193 public $withoptiononeemailperrecipient;
209 $this->withtofree = 1;
211 $this->withtoccc = 0;
212 $this->witherrorsto = 0;
213 $this->withtopic = 1;
215 $this->withmaindocfile = 0;
218 $this->withfromreadonly = 1;
219 $this->withreplytoreadonly = 1;
220 $this->withtoreadonly = 0;
221 $this->withtoccreadonly = 0;
222 $this->withtocccreadonly = 0;
223 $this->witherrorstoreadonly = 0;
224 $this->withtopicreadonly = 0;
225 $this->withfilereadonly = 0;
226 $this->withbodyreadonly = 0;
227 $this->withdeliveryreceiptreadonly = 0;
228 $this->withfckeditor = -1;
241 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
244 $vardir = $conf->user->dir_output.
"/".$user->id;
245 $upload_dir = $vardir.
'/temp/';
246 if (is_dir($upload_dir)) {
250 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
251 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
252 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
253 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
268 $listofpaths = array();
269 $listofnames = array();
270 $listofmimes = array();
273 $file = basename($path);
279 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
280 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
281 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
283 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
284 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
286 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
287 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
289 if (!in_array($file, $listofnames)) {
290 $listofpaths[] = $path;
291 $listofnames[] = $file;
292 $listofmimes[] = $type;
293 $_SESSION[
"listofpaths".$keytoavoidconflict] = implode(
';', $listofpaths);
294 $_SESSION[
"listofnames".$keytoavoidconflict] = implode(
';', $listofnames);
295 $_SESSION[
"listofmimes".$keytoavoidconflict] = implode(
';', $listofmimes);
309 $listofpaths = array();
310 $listofnames = array();
311 $listofmimes = array();
313 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
314 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
315 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
317 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
318 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
320 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
321 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
323 if ($keytodelete >= 0) {
324 unset($listofpaths[$keytodelete]);
325 unset($listofnames[$keytodelete]);
326 unset($listofmimes[$keytodelete]);
327 $_SESSION[
"listofpaths".$keytoavoidconflict] = implode(
';', $listofpaths);
328 $_SESSION[
"listofnames".$keytoavoidconflict] = implode(
';', $listofnames);
329 $_SESSION[
"listofmimes".$keytoavoidconflict] = implode(
';', $listofmimes);
343 $listofpaths = array();
344 $listofnames = array();
345 $listofmimes = array();
347 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
348 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
349 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
351 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
352 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
354 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
355 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
357 return array(
'paths' => $listofpaths,
'names' => $listofnames,
'mimes' => $listofmimes);
371 public function show_form($addfileaction =
'addfile', $removefileaction =
'removefile')
374 print $this->
get_form($addfileaction, $removefileaction);
388 public function get_form($addfileaction =
'addfile', $removefileaction =
'removefile')
391 global $conf, $langs, $user, $hookmanager, $form;
394 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
395 $formfile =
new FormFile($this->db);
397 if (!is_object($form)) {
398 $form =
new Form($this->db);
402 $langs->loadLangs(array(
'other',
'mails',
'members'));
405 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
410 $hookmanager->initHooks(array(
'formmail'));
413 'addfileaction' => $addfileaction,
414 'removefileaction' => $removefileaction,
415 'trackid' => $this->trackid
417 $reshook = $hookmanager->executeHooks(
'getFormMail', $parameters, $this);
419 if (!empty($reshook)) {
420 return $hookmanager->resPrint;
424 $disablebademails = 1;
427 $outputlangs = $langs;
429 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($this->param[
'langsmodels'])) {
430 $newlang = $this->param[
'langsmodels'];
432 if (!empty($newlang)) {
434 $outputlangs->setDefaultLang($newlang);
435 $outputlangs->load(
'other');
439 $arraydefaultmessage = -1;
440 if ($this->param[
'models'] !=
'none') {
442 if (array_key_exists(
'models_id', $this->param)) {
443 $model_id = $this->param[
"models_id"];
446 $arraydefaultmessage = $this->
getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id, 1,
'', ($model_id > 0 ? -1 : 1));
450 $listofpaths = array();
451 $listofnames = array();
452 $listofmimes = array();
453 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
455 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
456 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
457 foreach ($this->param[
'fileinit'] as $path) {
465 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
466 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
468 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
469 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
471 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
472 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
476 $out .=
"\n".
'<!-- Begin form mail type='.$this->param[
"models"].
' --><div id="mailformdiv"></div>'.
"\n";
477 if ($this->withform == 1) {
478 $out .=
'<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'#formmail">'.
"\n";
480 $out .=
'<a id="formmail" name="formmail"></a>';
481 $out .=
'<input style="display:none" type="submit" id="sendmailhidden" name="sendmail">';
482 $out .=
'<input type="hidden" name="token" value="'.newToken().
'" />';
483 $out .=
'<input type="hidden" name="trackid" value="'.$this->trackid.
'" />';
484 $out .=
'<input type="hidden" name="inreplyto" value="'.$this->inreplyto.
'" />';
486 if (!empty($this->withfrom)) {
487 if (!empty($this->withfromreadonly)) {
488 $out .=
'<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.
'" />';
489 $out .=
'<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.
'" />';
492 foreach ($this->param as $key => $value) {
493 if (is_array($value)) {
494 $out .=
"<!-- param key=".$key.
" is array, we do not output input field for it -->\n";
496 $out .=
'<input type="hidden" id="'.$key.
'" name="'.$key.
'" value="'.$value.
'" />'.
"\n";
500 $modelmail_array = array();
501 if ($this->param[
'models'] !=
'none') {
507 foreach ($this->lines_model as $line) {
509 if (preg_match(
'/\((.*)\)/', $line->label, $reg)) {
510 $labeltouse = $langs->trans($reg[1]);
512 $labeltouse = $line->label;
518 $modelmail_array[$line->id] .=
' '.picto_from_langcode($line->lang);
520 if ($line->private) {
521 $modelmail_array[$line->id] .=
' - <span class="opacitymedium">'.dol_escape_htmltag($langs->trans(
"Private")).
'</span>';
527 if (count($modelmail_array) > 0) {
528 $model_mail_selected_id =
GETPOSTISSET(
'modelmailselected') ?
GETPOSTINT(
'modelmailselected') : ($arraydefaultmessage->id > 0 ? $arraydefaultmessage->id : 0);
531 $out .=
'<div class="center" style="padding: 0px 0 12px 0">'.
"\n";
533 $out .=
'<span class="opacitymedium">'.$langs->trans(
'SelectMailModel').
':</span> ';
535 $out .= $this->
selectarray(
'modelmailselected', $modelmail_array, $model_mail_selected_id, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1,
'', 0, 1);
537 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv(
'Setup').
' - '.$langs->transnoentitiesnoconv(
'EMails')), 1);
541 $out .=
'<input type="submit" class="button reposition smallpaddingimp" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
544 } elseif (!empty($this->param[
'models']) && in_array($this->param[
'models'], array(
545 'propal_send',
'order_send',
'facture_send',
546 'shipping_send',
'fichinter_send',
'supplier_proposal_send',
'order_supplier_send',
547 'invoice_supplier_send',
'thirdparty',
'contract',
'user',
'recruitmentcandidature_send',
'all'
550 $out .=
'<div class="center" style="padding: 0px 0 12px 0">'.
"\n";
551 $out .=
'<span class="opacitymedium">'.$langs->trans(
'SelectMailModel').
':</span> ';
552 $out .=
'<select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans(
"NoTemplateDefined").
'</option></select>';
554 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv(
'Setup').
' - '.$langs->transnoentitiesnoconv(
'EMails')), 1);
557 $out .=
'<input type="submit" class="button reposition smallpaddingimp" value="'.$langs->trans(
'Apply').
'" name="modelselected" disabled="disabled" id="modelselected">';
561 $out .=
'<!-- No template available for $this->param["models"] = '.$this->param[
'models'].
' -->';
565 $out .=
'<table class="tableforemailform boxtablenotop centpercent">'.
"\n";
568 $helpforsubstitution =
'';
569 if (is_array($this->substit) && count($this->substit)) {
570 $helpforsubstitution .= $langs->trans(
'AvailableVariables').
' :<br><br><span class="small">'.
"\n";
572 foreach ($this->substit as $key => $val) {
574 if (in_array($key, array(
'__NEWREF__',
'__REFCLIENT__',
'__REFSUPPLIER__',
'__SUPPLIER_ORDER_DATE_DELIVERY__',
'__SUPPLIER_ORDER_DELAY_DELIVERY__'))) {
579 if (is_array($this->substit) && count($this->substit)) {
580 $helpforsubstitution .=
'</span>';
595 if (!empty($this->withfrom)) {
596 if (!empty($this->withfromreadonly)) {
597 $out .=
'<tr><td class="fieldrequired minwidth200">'.$langs->trans(
"MailFrom").
'</td><td>';
600 if (!($this->fromtype ===
'user' && $this->fromid > 0)
601 && !($this->fromtype ===
'company')
602 && !($this->fromtype ===
'robot')
603 && !preg_match(
'/user_aliases/', $this->fromtype)
604 && !preg_match(
'/global_aliases/', $this->fromtype)
605 && !preg_match(
'/senderprofile/', $this->fromtype)
608 $out .= $this->fromname;
609 if ($this->frommail) {
610 $out .=
' <'.$this->frommail.
'>';
612 if ($this->fromtype) {
613 $langs->load(
'errors');
614 $out .=
'<span class="warning"> <'.$langs->trans(
'ErrorNoMailDefinedForThisUser').
'> </span>';
621 if (empty($user->email)) {
622 $langs->load(
'errors');
623 $s = $user->getFullName($langs).
' <'.$langs->trans(
'ErrorNoMailDefinedForThisUser').
'>';
625 $s = $user->getFullName($langs).
' <'.$user->email.
'>';
627 $liste[
'user'] = array(
'label' => $s,
'data-html' => $s);
631 $s = (!
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM') ? $conf->global->MAIN_INFO_SOCIETE_EMAIL : $conf->global->MAIN_INFO_SOCIETE_NOM).
' <' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL').
'>';
632 $liste[
'company'] = array(
'label' => $s,
'data-html' => $s);
636 $listaliases = array(
637 'user_aliases' => (empty($user->email_aliases) ?
'' : $user->email_aliases),
641 if (!empty($arraydefaultmessage->email_from)) {
642 $templatemailfrom =
' <'.$arraydefaultmessage->email_from.
'>';
643 $liste[
'from_template_'.GETPOST(
'modelmailselected')] = array(
'label' => $templatemailfrom,
'data-html' => $templatemailfrom);
647 if (!empty($this->fromalsorobot)) {
650 if ($this->frommail) {
653 $liste[
'main_from'] = array(
'label' => $s,
'data-html' => $s);
658 $sql =
"SELECT rowid, label, email FROM ".$this->db->prefix().
"c_email_senderprofile";
659 $sql .=
" WHERE active = 1 AND (private = 0 OR private = ".((int) $user->id).
")";
660 $sql .=
" ORDER BY position";
661 $resql = $this->db->query(
$sql);
663 $num = $this->db->num_rows($resql);
666 $obj = $this->db->fetch_object($resql);
668 $listaliases[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
676 foreach ($listaliases as $typealias => $listalias) {
678 $listaliasarray = explode(
',', $listalias);
679 foreach ($listaliasarray as $listaliasval) {
681 $listaliasval = trim($listaliasval);
683 $listaliasval = preg_replace(
'/</',
'<', $listaliasval);
684 $listaliasval = preg_replace(
'/>/',
'>', $listaliasval);
685 if (!preg_match(
'/</', $listaliasval)) {
686 $listaliasval =
'<'.$listaliasval.
'>';
688 $liste[$typealias.
'_'.$posalias] = array(
'label' => $listaliasval,
'data-html' => $listaliasval);
696 foreach ($liste as $key => $val) {
697 if (!empty($liste[$key][
'data-html'])) {
698 $liste[$key][
'data-html'] = str_replace(array(
'<',
'<',
'>',
'>'), array(
'__LTCHAR__',
'__LTCHAR__',
'__GTCHAR__',
'__GTCHAR__'), $liste[$key][
'data-html']);
699 $liste[$key][
'data-html'] = str_replace(array(
'__LTCHAR__',
'__GTCHAR__'), array(
'<span class="opacitymedium">(',
')</span>'), $liste[$key][
'data-html']);
702 $out .=
' '.$form->selectarray(
'fromtype', $liste, empty($arraydefaultmessage->email_from) ? $this->fromtype :
'from_template_'.GETPOST(
'modelmailselected'), 0, 0, 0,
'', 0, 0, 0,
'',
'fromforsendingprofile maxwidth200onsmartphone', 1,
'', $disablebademails);
705 $out .=
"</td></tr>\n";
707 $out .=
'<tr><td class="fieldrequired width200">'.$langs->trans(
"MailFrom").
"</td><td>";
708 $out .= $langs->trans(
"Name").
':<input type="text" id="fromname" name="fromname" class="maxwidth200onsmartphone" value="'.$this->fromname.
'" />';
709 $out .=
' ';
710 $out .= $langs->trans(
"EMail").
':<<input type="text" id="frommail" name="frommail" class="maxwidth200onsmartphone" value="'.$this->frommail.
'" />>';
711 $out .=
"</td></tr>\n";
716 if (!empty($this->withto) || is_array($this->withto)) {
721 if (!empty($this->withtouser) && is_array($this->withtouser) &&
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
723 $out .= $langs->trans(
"MailToUsers");
727 $tmparray = $this->withtouser;
728 foreach ($tmparray as $key => $val) {
731 $withtoselected =
GETPOST(
"receiveruser",
'array');
732 if (empty($withtoselected) && count($tmparray) == 1 &&
GETPOST(
'action',
'aZ09') ==
'presend') {
733 $withtoselected = array_keys($tmparray);
735 $out .= $form->multiselectarray(
"receiveruser", $tmparray, $withtoselected,
null,
null,
'inline-block minwidth500',
null,
"");
736 $out .=
"</td></tr>\n";
740 if (!empty($this->withoptiononeemailperrecipient)) {
741 if (abs($this->withoptiononeemailperrecipient) == 1) {
742 $out .=
'<tr><td class="minwidth200">';
743 $out .= $langs->trans(
"GroupEmails");
745 $out .=
' <input type="checkbox" id="oneemailperrecipient" value="1" name="oneemailperrecipient"'.($this->withoptiononeemailperrecipient > 0 ?
' checked="checked"' :
'').
'> ';
746 $out .=
'<label for="oneemailperrecipient">';
747 $out .= $form->textwithpicto($langs->trans(
"OneEmailPerRecipient"), $langs->trans(
"WarningIfYouCheckOneRecipientPerEmail"), 1,
'help');
753 if (
getDolGlobalString(
'MASS_ACTION_EMAIL_ON_DIFFERENT_THIRPARTIES_ADD_CUSTOM_EMAIL')) {
754 if (!empty($this->withto) && !is_array($this->withto)) {
755 $out .=
' '.$langs->trans(
"or").
' <input type="email" name="emailto" value="">';
758 $out .=
'</td></tr>';
760 $out .=
'<tr><td><input type="hidden" name="oneemailperrecipient" value="1"></td><td></td></tr>';
765 if (!empty($this->withtocc) || is_array($this->withtocc)) {
770 if (!empty($this->withtoccuser) && is_array($this->withtoccuser) &&
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
772 $out .= $langs->trans(
"MailToCCUsers");
776 $tmparray = $this->withtoccuser;
777 foreach ($tmparray as $key => $val) {
780 $withtoselected =
GETPOST(
"receiverccuser",
'array');
781 if (empty($withtoselected) && count($tmparray) == 1 &&
GETPOST(
'action',
'aZ09') ==
'presend') {
782 $withtoselected = array_keys($tmparray);
784 $out .= $form->multiselectarray(
"receiverccuser", $tmparray, $withtoselected,
null,
null,
'inline-block minwidth500',
null,
"");
785 $out .=
"</td></tr>\n";
789 if (!empty($this->withtoccc) || is_array($this->withtoccc)) {
794 if (!empty($this->withreplyto)) {
795 if ($this->withreplytoreadonly) {
796 $out .=
'<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.
'" />';
797 $out .=
'<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.
'" />';
798 $out .=
"<tr><td>".$langs->trans(
"MailReply").
"</td><td>".$this->replytoname.($this->replytomail ? (
" <".$this->replytomail.
">") :
"");
799 $out .=
"</td></tr>\n";
804 if (!empty($this->witherrorsto)) {
809 if (!empty($this->withdeliveryreceipt) &&
getDolGlobalInt(
'MAIN_EMAIL_SUPPORT_ACK')) {
814 if (!empty($this->withtopic)) {
815 $out .= $this->
getHtmlForTopic($arraydefaultmessage, $helpforsubstitution);
819 if (!empty($this->withfile)) {
821 $out .=
'<td class="tdtop">'.$langs->trans(
"MailFile").
'</td>';
825 if ($this->withmaindocfile) {
828 $this->withmaindocfile = (
GETPOST(
'addmaindocfile',
'alpha') ? -1 : 1);
829 } elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
831 $this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1);
835 if (!empty($this->withmaindocfile)) {
836 if ($this->withmaindocfile == 1) {
837 $out .=
'<input type="checkbox" id="addmaindocfile" name="addmaindocfile" value="1" />';
838 } elseif ($this->withmaindocfile == -1) {
839 $out .=
'<input type="checkbox" id="addmaindocfile" name="addmaindocfile" value="1" checked="checked" />';
842 $out .=
' <label for="addmaindocfile">'.$langs->trans(
"JoinMainDocOrLastGenerated").
'.</label><br>';
844 $out .=
' <label for="addmaindocfile">'.$langs->trans(
"JoinMainDoc").
'.</label><br>';
848 if (is_numeric($this->withfile)) {
850 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
851 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
852 $out .=
'jQuery(document).ready(function () {';
853 $out .=
' jQuery(".removedfile").click(function() {';
854 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
857 $out .=
'</script>'.
"\n";
858 if (count($listofpaths)) {
859 foreach ($listofpaths as $key => $val) {
860 $relativepathtofile = substr($val, (strlen(DOL_DATA_ROOT) - strlen($val)));
862 if ($conf->entity > 1) {
863 $relativepathtofile = str_replace(
'/'.$conf->entity.
'/',
'/', $relativepathtofile);
866 $formfile_params = array();
867 preg_match(
'#^(/)(\w+)(/)(.+)$#', $relativepathtofile, $formfile_params);
869 $out .=
'<div id="attachfile_'.$key.
'">';
871 $out .=
img_mime($listofnames[$key]).$listofnames[$key];
873 $out .=
' '.$formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
874 if (!$this->withfilereadonly) {
875 $out .=
' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/delete.png" value="'.($key + 1).
'" class="removedfile input-nobottom" id="removedfile_'.$key.
'" name="removedfile_'.$key.
'" />';
878 $out .=
'<br></div>';
880 } elseif (empty($this->withmaindocfile)) {
883 if ($this->withfile == 2) {
885 $maxmin = $maxfilesizearray[
'maxmin'];
887 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
891 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile[]" value="'.$langs->trans(
"Upload").
'" multiple />';
893 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
896 $out .=
'<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
899 $out .= $this->withfile;
902 $out .=
"</td></tr>\n";
906 if (!empty($this->withbody)) {
907 $defaultmessage =
GETPOST(
'message',
'restricthtml');
908 if (!
GETPOST(
'modelselected',
'alpha') ||
GETPOST(
'modelmailselected') !=
'-1') {
909 if ($arraydefaultmessage && $arraydefaultmessage->content) {
910 $defaultmessage = $arraydefaultmessage->content;
911 } elseif (!is_numeric($this->withbody)) {
912 $defaultmessage = $this->withbody;
917 $validpaymentmethod = array();
918 if (empty($this->substit[
'__REF__'])) {
922 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
923 $langs->loadLangs(array(
'paypal',
'other'));
924 $typeforonlinepayment =
'free';
925 if ($this->param[
"models"] ==
'order' || $this->param[
"models"] ==
'order_send') {
926 $typeforonlinepayment =
'order';
928 if ($this->param[
"models"] ==
'invoice' || $this->param[
"models"] ==
'facture_send') {
929 $typeforonlinepayment =
'invoice';
931 if ($this->param[
"models"] ==
'member') {
932 $typeforonlinepayment =
'member';
934 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit[
'__REF__']);
937 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
940 if (count($validpaymentmethod) > 0 && $paymenturl) {
941 $langs->load(
'other');
942 $this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace(
'\n',
"\n", $langs->transnoentities(
"PredefinedMailContentLink", $paymenturl));
943 $this->substit[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
945 $this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
946 $this->substit[
'__ONLINE_PAYMENT_URL__'] =
'';
949 $this->substit[
'__ONLINE_INTERVIEW_SCHEDULER_TEXT_AND_URL__'] =
'';
953 $defaultlines = $arraydefaultmessage->content_lines;
954 if (isset($defaultlines)) {
955 foreach ($this->substit_lines as $substit_line) {
959 $this->substit[
'__LINES__'] = $lines;
961 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
964 $atleastonecomponentishtml = 0;
965 if (strpos($defaultmessage,
'__USER_SIGNATURE__') !==
false &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
966 $atleastonecomponentishtml++;
968 if (strpos($defaultmessage,
'__SENDEREMAIL_SIGNATURE__') !==
false &&
dol_textishtml($this->substit[
'__SENDEREMAIL_SIGNATURE__'])) {
969 $atleastonecomponentishtml++;
971 if (strpos($defaultmessage,
'__ONLINE_PAYMENT_TEXT_AND_URL__') !==
false &&
dol_textishtml($this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__'])) {
972 $atleastonecomponentishtml++;
974 if (strpos($defaultmessage,
'__ONLINE_INTERVIEW_SCHEDULER_TEXT_AND_URL__') !==
false &&
dol_textishtml($this->substit[
'__ONLINE_INTERVIEW_SCHEDULER_TEXT_AND_URL__'])) {
975 $atleastonecomponentishtml++;
978 $atleastonecomponentishtml++;
980 if ($atleastonecomponentishtml) {
982 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
984 if (!
dol_textishtml($this->substit[
'__SENDEREMAIL_SIGNATURE__'])) {
985 $this->substit[
'__SENDEREMAIL_SIGNATURE__'] =
dol_nl2br($this->substit[
'__SENDEREMAIL_SIGNATURE__']);
987 if (!
dol_textishtml($this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__'])) {
988 $this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
dol_nl2br($this->substit[
'__ONLINE_PAYMENT_TEXT_AND_URL__']);
991 $defaultmessage =
dol_nl2br($defaultmessage);
996 $defaultmessage =
GETPOST(
"message",
"restricthtml");
1000 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1001 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1005 $out .=
'<td class="tdtop">';
1006 $out .= $form->textwithpicto($langs->trans(
'MailText'), $helpforsubstitution, 1,
'help',
'', 0, 2,
'substittooltipfrombody');
1008 $out .=
'<td class="tdtop">';
1011 $showlinktolayout = $formmail->withlayout && $formmail->withfckeditor;
1012 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
1013 $showlinktoai = ($formmail->withaiprompt &&
isModEnabled(
'ai')) ?
'textgenerationemail' :
'';
1014 $showlinktoailabel = $langs->trans(
"FillMessageWithAIContent");
1015 $formatforouput =
'';
1016 $htmlname =
'message';
1019 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
1025 $out .=
'<td colspan="2">';
1026 if ($this->withbodyreadonly) {
1027 $out .= nl2br($defaultmessage);
1028 $out .=
'<input type="hidden" id="message" name="message" disabled value="'.$defaultmessage.
'" />';
1030 if (!isset($this->ckeditortoolbar)) {
1031 $this->ckeditortoolbar =
'dolibarr_mailings';
1035 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1036 if ($this->withfckeditor == -1) {
1038 $this->withfckeditor = 1;
1040 $this->withfckeditor = 0;
1044 $doleditor =
new DolEditor(
'message', $defaultmessage,
'', 280, $this->ckeditortoolbar,
'In',
true,
true, $this->withfckeditor, 8,
'95%');
1045 $out .= $doleditor->Create(1);
1047 $out .=
"</td></tr>\n";
1050 $out .=
'</table>'.
"\n";
1052 if ($this->withform == 1 || $this->withform == -1) {
1053 $out .=
'<div class="center">';
1054 $out .=
'<input type="submit" class="button button-add" id="sendmail" name="sendmail" value="'.$langs->trans(
"SendMail").
'"';
1056 if ($this->withfile == 2 && $conf->use_javascript_ajax) {
1057 $out .=
' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1060 if ($this->withcancel) {
1061 $out .= '<input class="button button-cancel
" type="submit
" id="cancel
" name="cancel
" value="'.$langs->trans("Cancel").'" />';
1063 $out .= '</div>'."\n
";
1066 if ($this->withform == 1) {
1067 $out .= '</form>'."\n
";
1070 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1071 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
1072 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">';
1073 $out .= 'jQuery(document).ready(function () {';
1074 $out .= ' $(document).on("keypress
", \'#mailform\', function (e) { /* Note this is called at every key pressed ! */
1075 var code = e.keyCode || e.which;
1077 console.log("Enter was intercepted and blocked
");
1083 $out .= '</script>';
1086 $out .= "<!-- End form mail -->\n
";
1097 public function getHtmlForTo()
1099 global $langs, $form;
1100 $out = '<tr><td class="fieldrequired
">';
1101 if ($this->withtofree) {
1102 $out .= $form->textwithpicto($langs->trans("MailTo
"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients
"));
1104 $out .= $langs->trans("MailTo
");
1106 $out .= '</td><td>';
1107 if ($this->withtoreadonly) {
1108 if (!empty($this->toname) && !empty($this->tomail)) {
1109 $out .= '<input type="hidden
" id="toname
" name="toname
" value="'.$this->toname.'" />';
1110 $out .= '<input type="hidden
" id="tomail
" name="tomail
" value="'.$this->tomail.'" />';
1111 if ($this->totype == 'thirdparty') {
1112 $soc = new Societe($this->db);
1113 $soc->fetch($this->toid);
1114 $out .= $soc->getNomUrl(1);
1115 } elseif ($this->totype == 'contact') {
1116 $contact = new Contact($this->db);
1117 $contact->fetch($this->toid);
1118 $out .= $contact->getNomUrl(1);
1120 $out .= $this->toname;
1122 $out .= ' <'.$this->tomail.'>';
1123 if ($this->withtofree) {
1124 $out .= '<br>'.$langs->trans("and
").' <input class="minwidth200
" id="sendto
" name="sendto
" value="'.(!is_array($this->withto) && !is_numeric($this->withto) ? (GETPOSTISSET("sendto") ? GETPOST("sendto") : $this->withto) : "").'" />';
1127 // Note withto may be a text like 'AllRecipientSelected'
1128 $out .= (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : "";
1131 // The free input of email
1132 if (!empty($this->withtofree)) {
1133 $out .= '<input class="minwidth200
" id="sendto
" name="sendto
" value="'.(($this->withtofree && !is_numeric($this->withtofree)) ? $this->withtofree : (!is_array($this->withto) && !is_numeric($this->withto) ? (GETPOSTISSET("sendto") ? GETPOST("sendto") : $this->withto) : "")).'" />';
1136 if (!empty($this->withto) && is_array($this->withto)) {
1137 if (!empty($this->withtofree)) {
1138 $out .= " ".$langs->trans("and
")."/
".$langs->trans("or
")." ";
1141 $tmparray = $this->withto;
1142 foreach ($tmparray as $key => $val) {
1143 if (is_array($val)) {
1144 $label = $val['label'];
1149 $tmparray[$key] = array();
1150 $tmparray[$key]['id'] = $key;
1152 $tmparray[$key]['label'] = $label;
1153 $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']);
1154 // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time
1155 $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true);
1157 $tmparray[$key]['labelhtml'] = $label;
1158 $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']);
1159 $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('<span class="opacitymedium
">(', ')</span>'), $tmparray[$key]['labelhtml']);
1162 $withtoselected = GETPOST("receiver
", 'array'); // Array of selected value
1163 if (!getDolGlobalInt('MAIN_MAIL_NO_WITH_TO_SELECTED')) {
1164 if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
1165 $withtoselected = array_keys($tmparray);
1169 $out .= $form->multiselectarray("receiver
", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', 0, 0);
1172 $out .= "</td></tr>\n
";
1181 public function getHtmlForCc()
1183 global $langs, $form;
1185 $out .= $form->textwithpicto($langs->trans("MailCC
"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients
"));
1186 $out .= '</td><td>';
1187 if ($this->withtoccreadonly) {
1188 $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
1190 $out .= '<input class="minwidth200
" id="sendtocc
" name="sendtocc
" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
1191 if (!empty($this->withtocc) && is_array($this->withtocc)) {
1192 $out .= " ".$langs->trans("and
")."/
".$langs->trans("or
")." ";
1194 $tmparray = $this->withtocc;
1195 foreach ($tmparray as $key => $val) {
1196 if (is_array($val)) {
1197 $label = $val['label'];
1202 $tmparray[$key] = array();
1203 $tmparray[$key]['id'] = $key;
1205 $tmparray[$key]['label'] = $label;
1206 $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']);
1207 // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time
1208 $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true);
1210 $tmparray[$key]['labelhtml'] = $label;
1211 $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']);
1212 $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('<span class="opacitymedium
">(', ')</span>'), $tmparray[$key]['labelhtml']);
1215 $withtoccselected = GETPOST("receivercc
", 'array'); // Array of selected value
1217 $out .= $form->multiselectarray("receivercc
", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', 0, 0);
1220 $out .= "</td></tr>\n
";
1230 public function getHtmlForWithCcc()
1232 global $langs, $form;
1235 $out .= $form->textwithpicto($langs->trans("MailCCC
"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients
"));
1236 $out .= '</td><td>';
1237 if (!empty($this->withtocccreadonly)) {
1238 $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : "";
1240 $out .= '<input class="minwidth200
" id="sendtoccc
" name="sendtoccc
" value="'.(GETPOSTISSET("sendtoccc") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
1241 if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
1242 $out .= " ".$langs->trans("and
")."/
".$langs->trans("or
")." ";
1244 $tmparray = $this->withtoccc;
1245 foreach ($tmparray as $key => $val) {
1246 if (is_array($val)) {
1247 $label = $val['label'];
1251 $tmparray[$key] = array();
1252 $tmparray[$key]['id'] = $key;
1254 $tmparray[$key]['label'] = $label;
1255 $tmparray[$key]['label'] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]['label']);
1256 // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time
1257 $tmparray[$key]['label'] = dol_htmlentities($tmparray[$key]['label'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', true);
1259 $tmparray[$key]['labelhtml'] = $label;
1260 $tmparray[$key]['labelhtml'] = str_replace(array('<', '<', '>', '>'), array('__LTCHAR__', '__LTCHAR__', '__GTCHAR__', '__GTCHAR__'), $tmparray[$key]['labelhtml']);
1261 $tmparray[$key]['labelhtml'] = str_replace(array('__LTCHAR__', '__GTCHAR__'), array('<span class="opacitymedium
">(', ')</span>'), $tmparray[$key]['labelhtml']);
1264 $withtocccselected = GETPOST("receiverccc
", 'array'); // Array of selected value
1266 $out .= $form->multiselectarray("receiverccc
", $tmparray, $withtocccselected, null, null, 'inline-block minwidth500', 0, 0);
1271 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROPOSAL_TO') && !empty($this->param['models']) && $this->param['models'] == 'propal_send') {
1272 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROPOSAL_TO');
1274 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_ORDER_TO') && !empty($this->param['models']) && $this->param['models'] == 'order_send') {
1275 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_ORDER_TO');
1277 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_INVOICE_TO') && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
1278 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_INVOICE_TO');
1280 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') {
1281 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO');
1283 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO') && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') {
1284 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO');
1286 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO') && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') {
1287 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO');
1289 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO') && !empty($this->param['models']) && $this->param['models'] == 'project') { // don't know why there is not '_send' at end of this models name.
1290 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO');
1292 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_SHIPMENT_TO') && !empty($this->param['models']) && $this->param['models'] == 'shipping_send') {
1293 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_SHIPMENT_TO');
1295 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_RECEPTION_TO') && !empty($this->param['models']) && $this->param['models'] == 'reception_send') {
1296 $showinfobcc = getDolGlobalString('MAIN_MAIL_AUTOCOPY_RECEPTION_TO');
1299 $out .= ' + '.$showinfobcc;
1301 $out .= "</td></tr>\n
";
1310 public function getHtmlForWithErrorsTo()
1314 //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
1315 $errorstomail = getDolGlobalString('MAIN_MAIL_ERRORS_TO', (!empty($this->errorstomail) ? $this->errorstomail : ''));
1316 if ($this->witherrorstoreadonly) {
1317 $out = '<tr><td>'.$langs->trans("MailErrorsTo
").'</td><td>';
1318 $out .= '<input type="hidden
" id="errorstomail
" name="errorstomail
" value="'.$errorstomail.'" />';
1319 $out .= $errorstomail;
1320 $out .= "</td></tr>\n
";
1322 $out = '<tr><td>'.$langs->trans("MailErrorsTo
").'</td><td>';
1323 $out .= '<input class="minwidth200
" id="errorstomail
" name="errorstomail
" value="'.$errorstomail.'" />';
1324 $out .= "</td></tr>\n
";
1334 public function getHtmlForDeliveryreceipt()
1338 $out = '<tr><td><label for="deliveryreceipt
">'.$langs->trans("DeliveryReceipt
").'</label></td><td>';
1340 if (!empty($this->withdeliveryreceiptreadonly)) {
1341 $out .= yn($this->withdeliveryreceipt);
1343 $defaultvaluefordeliveryreceipt = 0;
1344 if (getDolGlobalString('MAIL_FORCE_DELIVERY_RECEIPT_PROPAL') && !empty($this->param['models']) && $this->param['models'] == 'propal_send') {
1345 $defaultvaluefordeliveryreceipt = 1;
1347 if (getDolGlobalString('MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL') && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') {
1348 $defaultvaluefordeliveryreceipt = 1;
1350 if (getDolGlobalString('MAIL_FORCE_DELIVERY_RECEIPT_ORDER') && !empty($this->param['models']) && $this->param['models'] == 'order_send') {
1351 $defaultvaluefordeliveryreceipt = 1;
1353 if (getDolGlobalString('MAIL_FORCE_DELIVERY_RECEIPT_INVOICE') && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
1354 $defaultvaluefordeliveryreceipt = 1;
1356 if (getDolGlobalString('MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_ORDER') && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') {
1357 $defaultvaluefordeliveryreceipt = 1;
1359 //$out .= $form->selectyesno('deliveryreceipt', (GETPOSTISSET("deliveryreceipt
") ? GETPOST("deliveryreceipt
") : $defaultvaluefordeliveryreceipt), 1);
1360 $out .= '<input type="checkbox
" id="deliveryreceipt
" name="deliveryreceipt
" value="1
"'.((GETPOSTISSET("deliveryreceipt
") ? GETPOST("deliveryreceipt
") : $defaultvaluefordeliveryreceipt) ? ' checked="checked
"' : '').'>';
1362 $out .= "</td></tr>\n
";
1373 public function getHtmlForTopic($arraydefaultmessage, $helpforsubstitution)
1375 global $langs, $form;
1377 $defaulttopic = GETPOST('subject', 'restricthtml');
1379 if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') {
1380 if ($arraydefaultmessage && $arraydefaultmessage->topic) {
1381 $defaulttopic = $arraydefaultmessage->topic;
1382 } elseif (!is_numeric($this->withtopic)) {
1383 $defaulttopic = $this->withtopic;
1387 $defaulttopic = make_substitutions($defaulttopic, $this->substit);
1390 $out .= '<td class="fieldrequired
">';
1391 $out .= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic');
1394 if ($this->withtopicreadonly) {
1395 $out .= $defaulttopic;
1396 $out .= '<input type="hidden
" class="quatrevingtpercent
" id="subject
" name="subject
" value="'.$defaulttopic.'" />';
1398 $out .= '<input type="text
" class="quatrevingtpercent
" id="subject
" name="subject
" value="'.((GETPOSTISSET("subject") && !GETPOST('modelselected
')) ? GETPOST("subject") : ($defaulttopic ? $defaulttopic : '')).'" />';
1400 $out .= "</td></tr>\n
";
1412 public function getSectionForAIPrompt($function = 'textgeneration', $format = '', $htmlContent = 'message')
1416 $langs->load("other
");
1418 $htmlContent = preg_replace('/[^a-z0-9_]/', '', $htmlContent);
1420 $out = '<tr id="ai_input
" class="hidden
">';
1422 //$out .= $form->textwithpicto($langs->trans('HelpWithAI'), $langs->trans("YouCanMakeSomeInstructionForEmail
"));
1426 $out .= '<input type="text
" class="quatrevingtpercent
" id="ai_instructions
" name="instruction
" placeholder="'.$langs->trans("EnterYourAIPromptHere").'...
" />';
1427 $out .= '<input id="generate_button
" type="button" class="button smallpaddingimp
" value="'.$langs->trans('Generate
').'"/>';
1428 $out .= '<div id="ai_status_message
" class="fieldrequired hideobject marginrightonly margintoponly
">';
1429 $out .= '<i class="fa fa-spinner fa-spin fa-2x fa-fw valignmiddle marginrightonly
"></i>'.$langs->trans("AIProcessingPleaseWait
", getDolGlobalString('AI_API_SERVICE', 'chatgpt'));
1431 $out .= "</td></tr>\n
";
1433 $out .= "<script
type=
'text/javascript'>
1434 $(document).ready(
function() {
1436 $(
'#ai_instructions').keydown(
function(event) {
1437 if (event.keyCode === 13) {
1438 event.preventDefault();
1439 $(
'#generate_button').click();
1443 $(
'#generate_button').click(
function() {
1444 console.log(
'We click on generate ai button');
1446 var instructions = $(
'#ai_instructions').val();
1447 var timeoutfinished = 0;
1448 var apicallfinished = 0;
1450 $(
'#ai_status_message').show();
1451 $(
'.icon-container .loader').show();
1452 setTimeout(
function() {
1453 timeoutfinished = 1;
1454 if (apicallfinished) {
1455 $(
'#ai_status_message').hide();
1460 if (CKEDITOR.instances.
".$htmlContent.") {
1461 CKEDITOR.instances.
".$htmlContent.".setReadOnly(1);
1466 url:
'". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."',
1468 contentType:
'application/json',
1469 data: JSON.stringify({
1470 'format':
'".dol_escape_js($format)."',
1471 'function':
'".dol_escape_js($function)."',
1472 'instructions': instructions,
1474 success:
function(response) {
1475 console.log(
'Add response into field \'".$htmlContent."\': '+response);
1477 jQuery(
'#".$htmlContent."').val(response);
1478 jQuery(
'#".$htmlContent."preview').val(response);
1480 if (CKEDITOR.instances) {
1481 var editorInstance = CKEDITOR.instances.
".$htmlContent.";
1482 if (editorInstance) {
1483 editorInstance.setReadOnly(0);
1484 editorInstance.setData(response);
1486 var editorInstancepreview = CKEDITOR.instances.
".$htmlContent."preview;
1487 if (editorInstancepreview) {
1488 editorInstancepreview.setData(response);
1493 $(
'#ai_instructions').val(
'');
1495 apicallfinished = 1;
1496 if (timeoutfinished) {
1497 $(
'#ai_status_message').hide();
1500 error:
function(xhr,
status, error) {
1502 console.error(
'error ajax',
status, error);
1503 $(
'#ai_status_message').hide();
1520 public function getModelEmailTemplate($htmlContent = 'message')
1522 require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php';
1524 $out = '<div id="template-selector
" class="template-container hidden
">';
1529 'commerce' => 'commerce',
1533 foreach ($templates as $template => $templateFunction) {
1534 $contentHtml = getHtmlOfLayout($template);
1536 $out .= '<div class="template-option
" data-template="'.$template.'" data-content="'.htmlentities($contentHtml).'">';
1537 $out .= '<img class="maillayout
" alt="'.$template.'" src="'.DOL_URL_ROOT.'/theme/common/maillayout/
'.$template.'.png
" />';
1538 $out .= '<span class="template-option-text
">'.ucfirst($template).'</span>';
1543 $out .= '<script type="text/javascript
">
1544 $(document).ready(function() {
1545 $(".template-option
").click(function() {
1546 console.log("We choose a layout
for email
");
1547 $(".template-option
").removeClass("selected
");
1548 $(this).addClass("selected
");
1550 var template = $(this).data("template");
1551 var contentHtml = $(this).data("content
");
1553 jQuery("#
'.$htmlContent.'").val(contentHtml);
1554 var editorInstance = CKEDITOR.instances.'.$htmlContent.';
1555 if (editorInstance) {
1556 editorInstance.setData(contentHtml);
1582 public function getEMailTemplate($dbs, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '', $defaultfortype = -1)
1586 if ($id == -2 && empty($label)) {
1587 $this->error = 'LabelIsMandatoryWhenIdIs-2or-3';
1591 $ret = new ModelMail();
1593 $languagetosearch = (is_object($outputlangs) ? $outputlangs->defaultlang : '');
1594 // Define $languagetosearchmain to fall back on main language (for example to get 'es_ES' for 'es_MX')
1595 $tmparray = explode('_', $languagetosearch);
1596 $languagetosearchmain = $tmparray[0].'_'.strtoupper($tmparray[0]);
1597 if ($languagetosearchmain == $languagetosearch) {
1598 $languagetosearchmain = '';
1601 $sql = "SELECT
rowid, module, label, type_template, topic, email_from, joinfiles, content, content_lines, lang, email_from, email_to, email_tocc, email_tobcc
";
1602 $sql .= " FROM
".$dbs->prefix().'c_email_templates';
1603 $sql .= " WHERE (type_template =
'".$dbs->escape($type_template)."' OR type_template =
'all')
";
1604 $sql .= " AND entity IN (
".getEntity('c_email_templates').")
";
1605 $sql .= " AND (
private = 0 OR fk_user =
".((int) $user->id).")
"; // Get all public or private owned
1607 $sql .= " AND active =
".((int) $active);
1609 if ($defaultfortype >= 0) {
1610 $sql .= " AND defaultfortype =
".((int) $defaultfortype);
1613 $sql .= " AND label =
'".$dbs->escape($label)."'";
1615 if (!($id > 0) && $languagetosearch) {
1616 $sql .= " AND (lang =
'".$dbs->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang =
'".$dbs->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang =
'')
";
1619 $sql .= " AND
rowid =
".(int) $id;
1624 if ($languagetosearch) {
1625 $sql .= $dbs->order("position,lang,label
", "ASC,DESC,ASC
"); // We want line with lang set first, then with lang null or ''
1627 $sql .= $dbs->order("position,lang,label
", "ASC,ASC,ASC
"); // If no language provided, we give priority to lang not defined
1629 //$sql .= $dbs->plimit(1);
1632 $resql = $dbs->query($sql);
1634 dol_print_error($dbs);
1640 $obj = $dbs->fetch_object($resql);
1643 // If template is for a module, check module is enabled; if not, take next template
1645 $tempmodulekey = $obj->module;
1646 if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) {
1651 // If a record was found
1652 $ret->id = $obj->rowid;
1653 $ret->module = $obj->module;
1654 $ret->label = $obj->label;
1655 $ret->lang = $obj->lang;
1656 $ret->topic = $obj->topic;
1657 $ret->content = $obj->content;
1658 $ret->content_lines = $obj->content_lines;
1659 $ret->joinfiles = $obj->joinfiles;
1660 $ret->email_from = $obj->email_from;
1664 // If no record found
1666 // Not found with the provided label
1669 // If there is no template at all
1670 $defaultmessage = '';
1672 if ($type_template == 'body') {
1673 // Special case to use this->withbody as content
1674 $defaultmessage = $this->withbody;
1675 } elseif ($type_template == 'facture_send') {
1676 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice
");
1677 } elseif ($type_template == 'facture_relance') {
1678 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder
");
1679 } elseif ($type_template == 'propal_send') {
1680 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal
");
1681 } elseif ($type_template == 'supplier_proposal_send') {
1682 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal
");
1683 } elseif ($type_template == 'order_send') {
1684 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder
");
1685 } elseif ($type_template == 'order_supplier_send') {
1686 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder
");
1687 } elseif ($type_template == 'invoice_supplier_send') {
1688 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice
");
1689 } elseif ($type_template == 'shipping_send') {
1690 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping
");
1691 } elseif ($type_template == 'fichinter_send') {
1692 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter
");
1693 } elseif ($type_template == 'actioncomm_send') {
1694 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendActionComm
");
1695 } elseif (!empty($type_template)) {
1696 $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric
");
1699 $ret->label = 'default';
1700 $ret->lang = $outputlangs->defaultlang;
1702 $ret->joinfiles = 1;
1703 $ret->content = $defaultmessage;
1704 $ret->content_lines = '';
1725 public function isEMailTemplate($type_template, $user, $outputlangs)
1727 $sql = "SELECT label, topic, content, lang
";
1728 $sql .= " FROM
".$this->db->prefix().'c_email_templates';
1729 $sql .= " WHERE type_template=
'".$this->db->escape($type_template)."'";
1730 $sql .= " AND entity IN (
".getEntity('c_email_templates').")
";
1731 $sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user =
".((int) $user->id).")
";
1732 if (is_object($outputlangs)) {
1733 $sql .= " AND (lang =
'".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang =
'')
";
1735 $sql .= $this->db->order("lang,label
", "ASC
");
1738 $resql = $this->db->query($sql);
1740 $num = $this->db->num_rows($resql);
1741 $this->db->free($resql);
1744 $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror();
1759 public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active = 1)
1763 $sql = "SELECT
rowid, module, label, topic, content, content_lines, lang, fk_user,
private,
position";
1764 $sql .= " FROM
".$this->db->prefix().'c_email_templates';
1765 $sql .= " WHERE type_template IN (
'".$this->db->escape($type_template)."',
'all')
";
1766 $sql .= " AND entity IN (
".getEntity('c_email_templates').")
";
1767 $sql .= " AND (
private = 0 OR fk_user =
".((int) $user->id).")
"; // See all public templates or templates I own.
1769 $sql .= " AND active =
".((int) $active);
1771 //if (is_object($outputlangs)) $sql.= " AND (lang =
'".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang =
'')
"; // Return all languages
1772 $sql .= $this->db->order("position,lang,label
", "ASC
");
1775 $resql = $this->db->query($sql);
1777 $num = $this->db->num_rows($resql);
1778 $this->lines_model = array();
1779 while ($obj = $this->db->fetch_object($resql)) {
1780 // If template is for a module, check module is enabled.
1782 $tempmodulekey = $obj->module;
1783 if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) {
1788 $line = new ModelMail();
1789 $line->id = $obj->rowid;
1790 $line->label = $obj->label;
1791 $line->lang = $obj->lang;
1792 $line->fk_user = $obj->fk_user;
1793 $line->private = $obj->private;
1794 $line->position = $obj->position;
1795 $line->topic = $obj->topic;
1796 $line->content = $obj->content;
1797 $line->content_lines = $obj->content_lines;
1799 $this->lines_model[] = $line;
1801 $this->db->free($resql);
1804 $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror();
1819 public function setSubstitFromObject($object, $outputlangs)
1821 global $extrafields;
1823 $parameters = array();
1824 $tmparray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1825 complete_substitutions_array($tmparray, $outputlangs, null, $parameters);
1827 $this->substit = $tmparray;
1829 // Fill substit_lines with each object lines content
1830 if (is_array($object->lines)) {
1831 foreach ($object->lines as $line) {
1832 $substit_line = array(
1833 '__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '',
1834 '__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '',
1835 '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '',
1836 '__LABEL__' => isset($line->label) ? $line->label : '',
1837 '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '',
1838 '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', 0, $outputlangs),
1839 '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', 0, $outputlangs),
1840 '__QUANTITY__' => $line->qty,
1841 '__SUBPRICE__' => price($line->subprice),
1842 '__AMOUNT__' => price($line->total_ttc),
1843 '__AMOUNT_EXCL_TAX__' => price($line->total_ht)
1846 // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__
1847 if (!empty($line->fk_product)) {
1848 if (!is_object($extrafields)) {
1849 $extrafields = new ExtraFields($this->db);
1851 $product = new Product($this->db);
1852 $product->fetch($line->fk_product, '', '', 1);
1853 $product->fetch_optionals();
1855 $extrafields->fetch_name_optionals_label($product->table_element, true);
1857 if (!empty($extrafields->attributes[$product->table_element]['label']) && is_array($extrafields->attributes[$product->table_element]['label']) && count($extrafields->attributes[$product->table_element]['label']) > 0) {
1858 foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
1859 $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = isset($product->array_options['options_'.$key]) ? $product->array_options['options_'.$key] : '';
1863 $this->substit_lines[] = $substit_line;
1876 public static function getAvailableSubstitKey($mode = 'formemail', $object = null)
1880 $tmparray = array();
1881 if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') {
1882 $parameters = array('mode' => $mode);
1883 $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects
1884 complete_substitutions_array($tmparray, $langs, null, $parameters);
1886 if ($mode == 'formwithlines') {
1887 $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function
1889 if ($mode == 'formforlines') {
1890 $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function
1894 if ($mode == 'emailing') {
1895 $parameters = array('mode' => $mode);
1896 $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects
1897 complete_substitutions_array($tmparray, $langs, null, $parameters);
1899 // For mass emailing, we have different keys specific to the data into tagerts list
1900 $tmparray['__ID__'] = 'IdRecord';
1901 $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode';
1902 $tmparray['__EMAIL__'] = 'EMailRecipient';
1903 $tmparray['__LASTNAME__'] = 'Lastname';
1904 $tmparray['__FIRSTNAME__'] = 'Firstname';
1905 $tmparray['__MAILTOEMAIL__'] = 'TagMailtoEmail';
1906 $tmparray['__OTHER1__'] = 'Other1';
1907 $tmparray['__OTHER2__'] = 'Other2';
1908 $tmparray['__OTHER3__'] = 'Other3';
1909 $tmparray['__OTHER4__'] = 'Other4';
1910 $tmparray['__OTHER5__'] = 'Other5';
1911 $tmparray['__CHECK_READ__'] = $langs->trans('TagCheckMail');
1912 $tmparray['__UNSUBSCRIBE__'] = $langs->trans('TagUnsubscribe');
1913 $tmparray['__UNSUBSCRIBE_URL__'] = $langs->trans('TagUnsubscribe').' (URL)';
1915 $onlinepaymentenabled = 0;
1916 if (isModEnabled('paypal')) {
1917 $onlinepaymentenabled++;
1919 if (isModEnabled('paybox')) {
1920 $onlinepaymentenabled++;
1922 if (isModEnabled('stripe')) {
1923 $onlinepaymentenabled++;
1925 if ($onlinepaymentenabled && getDolGlobalString('PAYMENT_SECURITY_TOKEN')) {
1926 $tmparray['__SECUREKEYPAYMENT__'] = getDolGlobalString('PAYMENT_SECURITY_TOKEN');
1927 if (getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
1928 if (isModEnabled('member')) {
1929 $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember';
1931 if (isModEnabled('don')) {
1932 $tmparray['__SECUREKEYPAYMENT_DONATION__'] = 'SecureKeyPAYMENTUniquePerDonation';
1934 if (isModEnabled('invoice')) {
1935 $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice';
1937 if (isModEnabled('order')) {
1938 $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder';
1940 if (isModEnabled('contract')) {
1941 $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine';
1944 //Online payment link
1945 if (isModEnabled('member')) {
1946 $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember';
1948 if (isModEnabled('don')) {
1949 $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation';
1951 if (isModEnabled('invoice')) {
1952 $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice';
1954 if (isModEnabled('order')) {
1955 $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder';
1957 if (isModEnabled('contract')) {
1958 $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine';
1962 /* No need to show into tooltip help, option is not enabled
1963 $vars['__SECUREKEYPAYMENT__']='';
1964 $vars['__SECUREKEYPAYMENT_MEMBER__']='';
1965 $vars['__SECUREKEYPAYMENT_INVOICE__']='';
1966 $vars['__SECUREKEYPAYMENT_ORDER__']='';
1967 $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='';
1970 if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
1971 $tmparray['__PUBLICLINK_NEWMEMBERFORM__'] = 'BlankSubscriptionForm';
1975 foreach ($tmparray as $key => $val) {
1977 $tmparray[$key] = $key;
2022 public $content_lines;
2029 public $email_tobcc;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Class to manage a WYSIWYG editor.
Class to manage translations.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information in HTML for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getMaxFileSizeArray()
Return the max allowed for file upload.