| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2005 Laurent Destailleur <eldy@uers.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: fiche.php,v 1.23 2005/09/18 18:20:43 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/mailing/fiche.php,v $ 21 */ 22 23 /** 24 \file htdocs/comm/mailing/fiche.php 25 \ingroup mailing 26 \brief Fiche mailing, onglet général 27 \version $Revision: 1.23 $ 28 */ 29 30 require ("./pre.inc.php"); 31 32 $langs->load("mails"); 33 34 $user->getrights("mailing"); 35 36 if (! $user->rights->mailing->lire || $user->societe_id > 0) 37 accessforbidden(); 38 39 40 $message = ''; 41 42 43 // Action envoi mailing pour tous 44 if ($_GET["action"] == 'sendall') 45 { 46 // Pour des raisons de sécurité, on ne permet pas cette fonction via l'IHM, 47 // on affiche donc juste un message 48 $message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>'; 49 $message.="php ./scripts/mailing-send.php ".$_GET["id"]; 50 $_GET["action"]=''; 51 } 52 53 // Action envoi test mailing 54 if ($_POST["action"] == 'send') 55 { 56 $mil = new Mailing($db); 57 58 $mil->id = $_POST["mailid"]; 59 $mil->fromname = $_POST["fromname"]; 60 $mil->frommail = $_POST["frommail"]; 61 $mil->sendto = $_POST["sendto"]; 62 $mil->titre = $_POST["titre"]; 63 $mil->sujet = $_POST["subject"]; 64 $mil->body = $_POST["message"]; 65 66 if ($mil->sendto && $mil->sujet && $mil->body) 67 { 68 require_once (DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); 69 70 $sendto = $mil->sendto; 71 $from = $mil->fromname." <".$mil->frommail.">"; 72 $arr_file = array(); 73 $arr_mime = array(); 74 $arr_name = array(); 75 76 $mailfile = new CMailFile($mil->sujet,$sendto,$from,$mil->body,$arr_file,$arr_mime,$arr_name); 77 78 $result=$mailfile->sendfile(); 79 80 if($result) 81 { 82 $message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$from,$sendto).'</div>'; 83 } 84 else 85 { 86 $message='<div class="error">'.$langs->trans("ResultKo").'</div>'; 87 } 88 89 $_GET["action"]=''; 90 $_GET["id"]=$mil->id; 91 } 92 else 93 { 94 $message='<div class="error">'.$langs->trans("ErrorUnknown").'</div>'; 95 } 96 97 } 98 99 // Action ajout mailing 100 if ($_POST["action"] == 'add') 101 { 102 $message=''; 103 104 $mil = new Mailing($db); 105 106 $mil->email_from = trim($_POST["from"]); 107 $mil->titre = trim($_POST["titre"]); 108 $mil->sujet = trim($_POST["sujet"]); 109 $mil->body = trim($_POST["body"]); 110 111 if (! $mil->titre) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle")); 112 if (! $mil->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic")); 113 114 if (! $message) 115 { 116 if ($mil->create($user) >= 0) 117 { 118 Header("Location: fiche.php?id=".$mil->id); 119 exit; 120 } 121 $message=$mil->error; 122 } 123 124 $message='<div class="error">'.$message.'</div>'; 125 $_GET["action"]="create"; 126 } 127 128 // Action mise a jour mailing 129 if ($_POST["action"] == 'update') 130 { 131 $mil = new Mailing($db); 132 133 $mil->id = $_POST["id"]; 134 $mil->email_from = $_POST["from"]; 135 $mil->titre = $_POST["titre"]; 136 $mil->sujet = $_POST["sujet"]; 137 $mil->body = $_POST["body"]; 138 139 if ($mil->update()) 140 { 141 Header("Location: fiche.php?id=".$mil->id); 142 } 143 } 144 145 // Action confirmation validation 146 if ($_POST["action"] == 'confirm_valide') 147 { 148 149 if ($_POST["confirm"] == 'yes') 150 { 151 $mil = new Mailing($db); 152 153 if ($mil->fetch($_GET["id"]) == 0) 154 { 155 $mil->valid($user); 156 157 Header("Location: fiche.php?id=".$mil->id); 158 } 159 else 160 { 161 dolibarr_print_error($db); 162 } 163 } 164 else 165 { 166 Header("Location: fiche.php?id=".$_GET["id"]); 167 } 168 } 169 170 if ($_POST["action"] == 'confirm_approve') 171 { 172 173 if ($_POST["confirm"] == 'yes') 174 { 175 $mil = new Mailing($db); 176 177 if ($mil->fetch($_GET["id"]) == 0) 178 { 179 $mil->approve($user); 180 181 Header("Location: fiche.php?id=".$mil->id); 182 } 183 else 184 { 185 dolibarr_print_error($db); 186 } 187 } 188 else 189 { 190 Header("Location: fiche.php?id=".$_GET["id"]); 191 } 192 } 193 194 // Action confirmation suppression 195 if ($_POST["action"] == 'confirm_delete') 196 { 197 if ($_POST["confirm"] == 'yes') 198 { 199 $mil = new Mailing($db); 200 $mil->id = $_GET["id"]; 201 202 if ($mil->delete($mil->id)) 203 { 204 Header("Location: index.php"); 205 } 206 } 207 } 208 209 if ($_POST["cancel"] == $langs->trans("Cancel")) 210 { 211 $action = ''; 212 } 213 214 215 216 llxHeader("","","Fiche Mailing"); 217 218 219 /* 220 * Mailing en mode création 221 * 222 */ 223 224 $mil = new Mailing($db); 225 226 if ($_GET["action"] == 'create') 227 { 228 print '<form action="fiche.php" method="post">'."\n"; 229 print '<input type="hidden" name="action" value="add">'; 230 231 print_titre($langs->trans("NewMailing")); 232 233 if ($message) print "$message<br>"; 234 235 print '<table class="border" width="100%">'; 236 237 print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td><input class="flat" name="from" size="40" value="'.$conf->mailing->email_from.'"></td></tr>'; 238 print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td><input class="flat" name="titre" size="40" value=""></td></tr>'; 239 print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td><input class="flat" name="sujet" size="60" value=""></td></tr>'; 240 print '<tr><td width="25%" valign="top">'.$langs->trans("MailMessage").'<br>'; 241 print '<br><i>'.$langs->trans("CommonSubstitutions").':<br>'; 242 print '__ID__ = '.$langs->trans("IdRecord").'<br>'; 243 print '__EMAIL__ = '.$langs->trans("EMail").'<br>'; 244 print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>'; 245 print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>'; 246 print '</i></td>'; 247 print '<td><textarea cols="70" rows="10" name="body"></textarea></td></tr>'; 248 print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("CreateMailing").'"></td></tr>'; 249 print '</table>'; 250 print '</form>'; 251 } 252 else 253 { 254 $html = new Form($db); 255 256 if ($mil->fetch($_GET["id"]) == 0) 257 { 258 259 $h=0; 260 $head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; 261 $head[$h][1] = $langs->trans("MailCard"); 262 $hselected = $h; 263 $h++; 264 265 $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id; 266 $head[$h][1] = $langs->trans('MailRecipients'); 267 $h++; 268 269 /* 270 $head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id; 271 $head[$h][1] = $langs->trans("MailHistory"); 272 $h++; 273 */ 274 dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20)); 275 276 // Confirmation de la validation du mailing 277 if ($_GET["action"] == 'valide') 278 { 279 $html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valide"); 280 print '<br>'; 281 } 282 283 // Confirmation de l'approbation du mailing 284 if ($_GET["action"] == 'approve') 285 { 286 $html->form_confirm("fiche.php?id=".$mil->id,"Approuver le mailing","Confirmez-vous l'approbation du mailing ?","confirm_approve"); 287 print '<br>'; 288 } 289 290 // Confirmation de la suppression 291 if ($_GET["action"] == 'delete') 292 { 293 $html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete"); 294 print '<br>'; 295 } 296 297 298 if ($_GET["action"] != 'edit') 299 { 300 /* 301 * Mailing en mode visu 302 * 303 */ 304 305 print '<table class="border" width="100%">'; 306 307 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>'; 308 print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>'; 309 print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from).'</td></tr>'; 310 print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>').'</td></tr>'; 311 print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->statuts[$mil->statut].'</td></tr>'; 312 313 $uc = new User($db, $mil->user_creat); 314 $uc->fetch(); 315 print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>'.$uc->fullname.'</td>'; 316 print '<td>'.$langs->trans("Date").'</td>'; 317 print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_creat).'</td></tr>'; 318 319 if ($mil->statut > 0) 320 { 321 $uv = new User($db, $mil->user_valid); 322 $uv->fetch(); 323 print '<tr><td>'.$langs->trans("ValidatedBy").'</td><td>'.$uv->fullname.'</td>'; 324 print '<td>'.$langs->trans("Date").'</td>'; 325 print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_valid).'</td></tr>'; 326 } 327 328 if ($mil->statut > 1) 329 { 330 print '<tr><td>'.$langs->trans("SentBy").'</td><td>'.$langs->trans("Unknown").'</td>'; 331 print '<td>'.$langs->trans("Date").'</td>'; 332 print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_envoi).'</td></tr>'; 333 } 334 335 // Contenu du mail 336 print '<tr><td>'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>'; 337 print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>'; 338 339 print '<td colspan="3">'; 340 print nl2br($mil->body).'</td></tr>'; 341 342 print '</table>'; 343 344 print "</div>"; 345 346 if ($message) print "$message<br>"; 347 348 /* 349 * Boutons d'action 350 */ 351 if ($_GET["action"] == '') 352 { 353 print "\n\n<div class=\"tabsAction\">\n"; 354 355 if ($mil->statut == 0 && $user->rights->mailing->creer) 356 { 357 print '<a class="butAction" href="fiche.php?action=edit&id='.$mil->id.'">'.$langs->trans("EditMailing").'</a>'; 358 } 359 360 //print '<a class="butAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("PreviewMailing").'</a>'; 361 362 print '<a class="butAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("TestMailing").'</a>'; 363 364 if ($mil->statut == 0 && $mil->nbemail > 0 && $user->rights->mailing->valider) 365 { 366 print '<a class="butAction" href="fiche.php?action=valide&id='.$mil->id.'">'.$langs->trans("ValidMailing").'</a>'; 367 } 368 369 if ($mil->statut == 1 && $mil->nbemail > 0 && $user->rights->mailing->valider) 370 { 371 print '<a class="butAction" href="fiche.php?action=sendall&id='.$mil->id.'">'.$langs->trans("SendMailing").'</a>'; 372 } 373 374 if ($mil->statut <= 1 && $user->rights->mailing->supprimer) 375 { 376 print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>'; 377 } 378 379 print '<br /><br /></div>'; 380 } 381 382 383 if ($_GET["action"] == 'test') 384 { 385 print_titre($langs->trans("TestMailing")); 386 387 // Créé l'objet formulaire mail 388 include_once ("../../html.formmail.class.php"); 389 $formmail = new FormMail($db); 390 $formmail->fromname = $mil->email_from; 391 $formmail->frommail = $mil->email_from; 392 $formmail->withfrom=1; 393 $formmail->withto=$user->email?$user->email:1; 394 $formmail->withcc=0; 395 $formmail->withtopic=$mil->sujet; 396 $formmail->withtopicreadonly=1; 397 $formmail->withfile=0; 398 $formmail->withbody=$mil->body; 399 $formmail->withbodyreadonly=1; 400 // Tableau des substitutions 401 $formmail->substit["__FACREF__"]=$fac->ref; 402 // Tableau des paramètres complémentaires du post 403 $formmail->param["action"]="send"; 404 $formmail->param["models"]="body"; 405 $formmail->param["mailid"]=$mil->id; 406 $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; 407 408 $formmail->show_form(); 409 } 410 411 } 412 else 413 { 414 /* 415 * Mailing en mode edition 416 */ 417 print '<form action="fiche.php" method="post">'."\n"; 418 print '<input type="hidden" name="action" value="update">'; 419 print '<input type="hidden" name="id" value="'.$mil->id.'">'; 420 print '<table class="border" width="100%">'; 421 422 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>'; 423 print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3"><input class="flat" type="text" size=40 name="titre" value="'.htmlentities($mil->titre).'"></td></tr>'; 424 print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3"><input class="flat" type="text" size=40 name="from" value="'.htmlentities($mil->email_from).'"></td></tr>'; 425 print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td colspan="3"><input class="flat" type="text" size=60 name="sujet" value="'.htmlentities($mil->sujet).'"></td></tr>'; 426 print '<tr><td width="25%" valign="top">'.$langs->trans("MailMessage").'<br>'; 427 print '<br><i>'.$langs->trans("CommonSubstitutions").':<br>'; 428 print '__ID__ = '.$langs->trans("IdRecord").'<br>'; 429 print '__EMAIL__ = '.$langs->trans("EMail").'<br>'; 430 print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>'; 431 print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>'; 432 print '</i></td>'; 433 print '<td colspan="3"><textarea name="body" cols=70 rows=10>'; 434 print $mil->body.'</textarea></td></tr>'; 435 436 print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>'; 437 print '</table>'; 438 print '</form>'; 439 440 print "</div>"; 441 } 442 } 443 444 } 445 446 $db->close(); 447 448 llxFooter('$Date: 2005/09/18 18:20:43 $ - $Revision: 1.23 $'); 449 ?>
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 |
|