[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: html.formmail.class.php,v 1.12 2005/10/19 05:44:24 eldy Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/html.formmail.class.php,v $ 20 */ 21 22 /** 23 \file htdocs/html.formmail.class.php 24 \brief Fichier de la classe permettant la génération du formulaire html d'envoi de mail unitaire 25 \version $Revision: 1.12 $ 26 */ 27 28 require_once (DOL_DOCUMENT_ROOT ."/html.form.class.php"); 29 30 31 /** \class FormMail 32 \brief Classe permettant la génération du formulaire html d'envoi de mail unitaire 33 \remarks Utilisation: $formail = new FormMail($db) 34 \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs 35 \remarks $formmail->show_form() affiche le formulaire 36 */ 37 38 class FormMail 39 { 40 var $db; 41 42 var $fromname; 43 var $frommail; 44 var $replytoname; 45 var $replytomail; 46 var $toname; 47 var $tomail; 48 49 var $withfrom; 50 var $withto; 51 var $withtocc; 52 var $withtopic; 53 var $withfile; 54 var $withbody; 55 56 var $withfromreadonly; 57 var $withreplytoreadonly; 58 var $withtoreadonly; 59 var $withtoccreadonly; 60 var $withtopicreadonly; 61 62 var $substit=array(); 63 var $param=array(); 64 65 var $errorstr; 66 67 /** \brief Constructeur 68 \param DB handler d'accès base de donnée 69 */ 70 71 function FormMail($DB) 72 { 73 $this->db = $DB; 74 75 $this->withfrom=1; 76 $this->withto=1; 77 $this->withtocc=1; 78 $this->withtopic=1; 79 $this->withfile=0; 80 $this->withbody=1; 81 82 $this->withfromreadonly=1; 83 $this->withreplytoreadonly=1; 84 $this->withtoreadonly=0; 85 $this->withtoccreadonly=0; 86 $this->withtopicreadonly=0; 87 $this->withbodyreadonly=0; 88 89 return 1; 90 } 91 92 93 /* 94 * \brief Effectue les substitutions des mots clés par les données en fonction du tableau $this->substit 95 * \param chaine chaine dans laquelle faire les substitutions 96 * \return string chaine avec les substitutions effectuées 97 */ 98 function make_substitutions($chaine) 99 { 100 foreach ($this->substit as $key=>$value) { 101 $chaine=ereg_replace($key,$value,$chaine); 102 } 103 return $chaine; 104 } 105 106 107 /* 108 * \brief Affiche la partie de formulaire pour saisie d'un mail en fonction des propriétés 109 */ 110 function show_form() { 111 global $conf, $langs, $user; 112 113 $langs->load("other"); 114 $langs->load("mails"); 115 116 $form=new Form($DB); 117 118 print "\n<!-- Debut form mail -->\n"; 119 print "<form method=\"post\" ENCTYPE=\"multipart/form-data\" action=\"".$this->param["returnurl"]."\">\n"; 120 foreach ($this->param as $key=>$value) { 121 print "<input type=\"hidden\" name=\"$key\" value=\"$value\">\n"; 122 } 123 print "<table class=\"border\" width=\"100%\">\n"; 124 125 // From 126 if ($this->withfrom) 127 { 128 if ($this->withfromreadonly) { 129 print '<input type="hidden" name="fromname" value="'.$this->fromname.'">'; 130 print '<input type="hidden" name="frommail" value="'.$this->frommail.'">'; 131 print "<tr><td width=\"180\">".$langs->trans("MailFrom")."</td><td>".$this->fromname.($this->frommail?(" <".$this->frommail.">"):"")."</td></tr>\n"; 132 print "</td></tr>\n"; 133 } 134 } 135 136 // Replyto 137 if ($this->withreplyto) 138 { 139 if ($this->withreplytoreadonly) { 140 print '<input type="hidden" name="replyname" value="'.$this->replytoname.'">'; 141 print '<input type="hidden" name="replymail" value="'.$this->replytomail.'">'; 142 print "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); 143 print "</td></tr>\n"; 144 } 145 } 146 147 // To 148 if ($this->withto || is_array($this->withto)) { 149 print '<tr><td width="180">'.$langs->trans("MailTo").'</td><td>'; 150 if ($this->withtoreadonly) { 151 print (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; 152 } else { 153 print "<input size=\"30\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)?$this->withto:"")."\">"; 154 if (is_array($this->withto)) 155 { 156 print " ".$langs->trans("or")." "; 157 $form->select_array("receiver",$this->withto); 158 } 159 } 160 print "</td></tr>\n"; 161 } 162 163 // CC 164 if ($this->withcc) 165 { 166 print '<tr><td width="180">'.$langs->trans("MailCC").'</td><td>'; 167 if ($this->withtoccreadonly) { 168 print (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; 169 } else { 170 print "<input size=\"30\" name=\"sendtocc\" value=\"".((! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"")."\">"; 171 if (is_array($this->withtocc)) 172 { 173 print " ".$langs->trans("or")." "; 174 $form->select_array("receivercc",$this->withtocc); 175 } 176 } 177 print "</td></tr>\n"; 178 } 179 180 // Topic 181 if ($this->withtopic) 182 { 183 $this->withtopic=$this->make_substitutions($this->withtopic); 184 185 print "<tr>"; 186 print "<td width=\"180\">".$langs->trans("MailTopic")."</td>"; 187 print "<td>"; 188 if ($this->withtopicreadonly) { 189 print $this->withtopic; 190 print "<input type=\"hidden\" size=\"60\" name=\"subject\" value=\"".$this->withtopic."\">"; 191 } 192 else 193 { 194 print "<input type=\"text\" size=\"60\" name=\"subject\" value=\"".$this->withtopic."\">"; 195 } 196 print "</td></tr>\n"; 197 } 198 199 // Si fichier joint 200 if ($this->withfile) 201 { 202 print "<tr>"; 203 print "<td width=\"180\">".$langs->trans("MailFile")."</td>"; 204 print "<td>"; 205 print "<input type=\"file\" class=\"flat\" name=\"addedfile\" value=\"".$langs->trans("Upload")."\"/>"; 206 print "</td></tr>\n"; 207 } 208 209 // Message 210 if ($this->withbody) 211 { 212 $defaultmessage=""; 213 214 // \todo A partir du type, proposer liste de messages dans table llx_models 215 if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; } 216 if ($this->param["models"]=='facture_send') { $defaultmessage="Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n"; } 217 if ($this->param["models"]=='facture_relance') { $defaultmessage="Nous apportons à votre connaissance que la facture __FACREF__ ne semble pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; } 218 if ($this->param["models"]=='propal_send') { $defaultmessage="Veuillez trouver ci-joint la proposition commerciale __PROPREF__\n\nCordialement\n\n"; } 219 220 $defaultmessage=$this->make_substitutions($defaultmessage); 221 222 print "<tr>"; 223 print "<td width=\"180\" valign=\"top\">".$langs->trans("MailText")."</td>"; 224 print "<td>"; 225 if ($this->withbodyreadonly) 226 { 227 print nl2br($defaultmessage); 228 print '<input type="hidden" name="message" value="'.$defaultmessage.'">'; 229 } 230 else 231 { 232 print '<textarea cols="72" rows="8" name="message">'; 233 print $defaultmessage; 234 print '</textarea>'; 235 } 236 print "</td></tr>\n"; 237 } 238 239 print "<tr><td align=center colspan=2><center><input class=\"button\" type=\"submit\" value=\"".$langs->trans("SendMail")."\"></center></td></tr>\n"; 240 print "</table>\n"; 241 242 print "</form>\n"; 243 print "<!-- Fin form mail -->\n"; 244 } 245 246 247 /* 248 * \brief Affiche la partie de formulaire pour saisie d'un mail 249 * \param withtopic 1 pour proposer à la saisie le sujet 250 * \param withbody 1 pour proposer à la saisie le corps du message 251 * \param withfile 1 pour proposer à la saisie l'ajout d'un fichier joint 252 * \todo Fonction a virer quand fichier /comm/mailing.php viré (= quand ecran dans /comm/mailing prets) 253 */ 254 function mail_topicmessagefile($withtopic=1,$withbody=1,$withfile=1,$defaultbody) { 255 global $langs; 256 257 $langs->load("other"); 258 259 print "<table class=\"border\" width=\"100%\">"; 260 261 // Topic 262 if ($withtopic) 263 { 264 print "<tr>"; 265 print "<td width=\"180\">".$langs->trans("MailTopic")."</td>"; 266 print "<td>"; 267 print "<input type=\"text\" size=\"60\" name=\"subject\" value=\"\">"; 268 print "</td></tr>"; 269 } 270 271 // Message 272 if ($withbody) 273 { 274 print "<tr>"; 275 print "<td width=\"180\" valign=\"top\">".$langs->trans("MailText")."</td>"; 276 print "<td>"; 277 print "<textarea rows=\"8\" cols=\"72\" name=\"message\">"; 278 print $defaultbody; 279 print "</textarea>"; 280 print "</td></tr>"; 281 } 282 283 // Si fichier joint 284 if ($withfile) 285 { 286 print "<tr>"; 287 print "<td width=\"180\">".$langs->trans("MailFile")."</td>"; 288 print "<td>"; 289 print "<input type=\"file\" name=\"addedfile\" value=\"".$langs->trans("Upload")."\"/>"; 290 print "</td></tr>"; 291 } 292 293 print "</table>"; 294 } 295 296 } 297 298 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |