';
- if ($this->withtoreadonly) {
- if (!empty($this->toname) && !empty($this->tomail)) {
- $out .= '';
- $out .= '';
- if ($this->totype == 'thirdparty') {
- $soc = new Societe($this->db);
- $soc->fetch($this->toid);
- $out .= $soc->getNomUrl(1);
- } elseif ($this->totype == 'contact') {
- $contact = new Contact($this->db);
- $contact->fetch($this->toid);
- $out .= $contact->getNomUrl(1);
- } else {
- $out .= $this->toname;
- }
- $out .= ' <'.$this->tomail.'>';
- if ($this->withtofree) {
- $out .= ' '.$langs->trans("and").' withto) : "").'" />';
- }
- } else {
- // Note withto may be a text like 'AllRecipientSelected'
- $out .= (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : "";
- }
- } else {
- // The free input of email
- if (!empty($this->withtofree)) {
- $out .= 'withto) : "")).'" />';
- }
- // The select combo
- if (!empty($this->withto) && is_array($this->withto)) {
- if (!empty($this->withtofree)) {
- $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
- }
- // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
- $tmparray = $this->withto;
- foreach ($tmparray as $key => $val) {
- $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
- }
-
- $withtoselected = GETPOST("receiver", 'array'); // Array of selected value
-
- if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
- $withtoselected = array_keys($tmparray);
- }
- $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
- }
- }
- $out .= "
\n";
+ $out .= $this->getHtmlForTo();
}
// To User
@@ -751,25 +697,7 @@ class FormMail extends Form
// CC
if (!empty($this->withtocc) || is_array($this->withtocc)) {
- $out .= '
';
- if ($this->withtoccreadonly) {
- $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
- } else {
- $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
- if (!empty($this->withtocc) && is_array($this->withtocc)) {
- $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
- // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
- $tmparray = $this->withtocc;
- foreach ($tmparray as $key => $val) {
- $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
- }
- $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value
- $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, "");
- }
- }
- $out .= "
\n";
+ $out .= $this->getHtmlForCc();
}
// To User cc
@@ -1065,6 +993,102 @@ class FormMail extends Form
}
}
+ /**
+ * get html For To
+ *
+ * @return string html
+ */
+ public function getHtmlForTo()
+ {
+ global $langs, $form;
+ $out = '
';
+ if ($this->withtoreadonly) {
+ if (!empty($this->toname) && !empty($this->tomail)) {
+ $out .= '';
+ $out .= '';
+ if ($this->totype == 'thirdparty') {
+ $soc = new Societe($this->db);
+ $soc->fetch($this->toid);
+ $out .= $soc->getNomUrl(1);
+ } elseif ($this->totype == 'contact') {
+ $contact = new Contact($this->db);
+ $contact->fetch($this->toid);
+ $out .= $contact->getNomUrl(1);
+ } else {
+ $out .= $this->toname;
+ }
+ $out .= ' <'.$this->tomail.'>';
+ if ($this->withtofree) {
+ $out .= ' '.$langs->trans("and").' withto) : "").'" />';
+ }
+ } else {
+ // Note withto may be a text like 'AllRecipientSelected'
+ $out .= (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : "";
+ }
+ } else {
+ // The free input of email
+ if (!empty($this->withtofree)) {
+ $out .= 'withto) : "")).'" />';
+ }
+ // The select combo
+ if (!empty($this->withto) && is_array($this->withto)) {
+ if (!empty($this->withtofree)) {
+ $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
+ }
+ // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
+ $tmparray = $this->withto;
+ foreach ($tmparray as $key => $val) {
+ $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
+ }
+
+ $withtoselected = GETPOST("receiver", 'array'); // Array of selected value
+
+ if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
+ $withtoselected = array_keys($tmparray);
+ }
+ $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
+ }
+ }
+ $out .= "
\n";
+ return $out;
+ }
+
+ /**
+ * get html For CC
+ *
+ * @return string html
+ */
+ public function getHtmlForCc()
+ {
+ global $langs, $form;
+ $out = '