From aa3127f3b87baa3d7178408e268e7ed0dbdf5540 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Feb 2004 22:16:57 +0000 Subject: [PATCH] =?UTF-8?q?La=20fonction=20d'envoi=20de=20facture=20par=20?= =?UTF-8?q?mails=20ne=20fonctionnait=20plus.=20Tous=20les=20appels=20=E0?= =?UTF-8?q?=20CMailFile=20fournissent=20maintenant=20un=20tableau=20de=20l?= =?UTF-8?q?a=20liste=20des=20fichiers=20=E0=20joindre.=20Si=20il=20n'y=20e?= =?UTF-8?q?n=20a=20qu'un,=20il=20s'agira=20d'un=20tableau=20d'un=20seul=20?= =?UTF-8?q?=E9l=E9ment.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 3 +- htdocs/compta/facture.php | 128 ++++++++++++++++++--------------- htdocs/facture.class.php | 7 +- htdocs/lib/CMailFile.class.php | 48 +++++++------ htdocs/notify.class.php | 6 +- 5 files changed, 109 insertions(+), 83 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 1985d5746a5..0a55ffe52f2 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -615,7 +616,7 @@ if ($_GET["propalid"]) $mimetype[1] = $_FILES['addedfile']['type']; $replyto = "$replytoname <$replytomail>"; - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename,$sendtocc); + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$sendtocc); if (! $mailfile->sendfile() ) { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e640179031c..8960bc8a850 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -274,7 +274,7 @@ if ($action == 'send') $replyto = $HTTP_POST_VARS["replytoname"] . " <".$HTTP_POST_VARS["replytomail"] .">"; - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$file, "application/pdf", $filename); + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,array ($file),array ("application/pdf"),array ($filename)); if ( $mailfile->sendfile() ) { @@ -306,7 +306,7 @@ if ($action == 'send') } else { - dolibarr_syslog("Impossible de lire les données de la facture"); + dolibarr_syslog("Impossible de lire les données de la facture. Le fichier facture n'a peut-être pas été généré."); } } /* @@ -935,58 +935,13 @@ else { print '

'; + // Supprimer if ($fac->statut == 0 && $user->rights->facture->supprimer) { print ""; } - elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer) - { - print ""; - } - else - { - print ""; - } - - if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement) - { - print ''; - } - else - { - print ''; - } - - if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0) - { - if ($user->rights->facture->paiement) - { - print ""; - } - else - { - print ''; - } - } - elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer) - { - print ""; - } - else - { - print ''; - } - if ($fac->statut > 0) - { - print ''; - } - else - { - print ''; - } - + // Valider if ($fac->statut == 0 && $fac->total_ht > 0) { if ($user->rights->facture->valider) @@ -997,8 +952,10 @@ else { print ''; } - } - elseif ($fac->statut == 1 && ($fac->paye == 0 || $user->admin)) + } + else { + // Générer + if ($fac->statut == 1 && ($fac->paye == 0 || $user->admin)) { if ($user->rights->facture->creer) { @@ -1018,7 +975,64 @@ else { print ''; } + } + // Envoyer + if ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer) + { + print ""; + } + else + { + print ""; + } + + // Envoyer une relance + if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer) + { + print ""; + } + else + { + print ''; + } + + // Emettre paiement + if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement) + { + print ''; + } + else + { + print ''; + } + + // Classer 'payé' + if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0) + { + if ($user->rights->facture->paiement) + { + print ""; + } + else + { + print ''; + } + } + + // Récurrente + if (! defined("FACTURE_NORECURENTE")) { // Possibilité de désactiver les factures récurrentes + if ($fac->statut > 0) + { + print ''; + } + else + { + print ''; + } + } + print "
id&action=delete\">Supprimerid&action=presend\">Envoyer-'; - print 'Emettre un paiement-id&action=payed\">Classer 'Payée'-id&action=prerelance\">Envoyer une relance-Récurrente---id&action=presend\">Envoyer-id&action=prerelance\">Envoyer une relance-'; + print 'Emettre un paiement-id&action=payed\">Classer 'Payée'-Récurrente-
"; } print "

\n"; @@ -1121,14 +1135,14 @@ else print "

Envoyer la facture par mail"; print ""; + print ""; + print ""; print '"; - print ""; - print ""; print "
Expéditeur$from_name$from_mail  
Reply-to$replytoname$replytomail  
Destinataire'; $form = new Form($db); $form->select_array("destinataire",$soc->contact_email_array()); print "email\">
Expéditeur$from_name$from_mail  
Reply-to$replytoname$replytomail  
"; print ""; @@ -1149,15 +1163,15 @@ else print_titre("Envoyer une relance"); print ""; + print "\n"; + print "\n"; print '"; - print ""; - print ""; - print "
Expéditeur$from_name$from_mail
Reply-to$replytoname$replytomail
Destinataire'; $form = new Form($db); $form->select_array("destinataire",$soc->contact_email_array()); - print "email\">
Expéditeur$from_name$from_mail
Reply-to$replytoname$replytomail
"; + print "email\">\n"; + print ""; print ""; } diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 021832c4761..18a0bb61d63 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -737,9 +737,10 @@ class Facture $sendto, $replyto, $message, - $file, - "application/pdf", - $filename); + array($file), + array("application/pdf"), + array($filename) + ); if ( $mailfile->sendfile() ) { diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index a1bb546de30..58d816d3872 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -22,6 +22,10 @@ to chunk_split Éric Seigne 2004.01.08 - ajout de la gestion du Cc - ajout de l'expédition de plusieurs fichiers + + Laurent Destailleur 2004.02.10 + - Correction d'un disfonctionnement suite à modif précédente sur la gestion + des attachements multi-fichiers */ // simple class that encapsulates mail() with addition of mime file attachment. @@ -36,28 +40,30 @@ class CMailFile var $mime_boundary = "--==================_846811060==_"; var $smtp_headers; - function CMailFile($subject,$to,$from,$msg,$filename,$mimetype = "application/octet-stream", $mime_filename = false, $addr_cc = "") + // CMail("sujet","email_to","email_from","email_msg",tableau du path de fichiers,tableau de type mime,tableau de noms fichiers,"chaine cc") + function CMailFile($subject,$to,$from,$msg,$filename_list,$mimetype_list,$mimefilename_list,$addr_cc = "") { $this->subject = $subject; $this->addr_to = $to; $this->smtp_headers = $this->write_smtpheaders($from,$addr_cc); - if (strlen($filename[0])) { - $this->mime_headers = $this->write_mimeheaders($filename[0], $mime_filename[0]); - $this->text_body = $this->write_body($msg, $filename[0]); - $this->text_encoded = $this->attach_file($filename,$mimetype,$mime_filename); + $this->text_body = $this->write_body($msg, $filename_list); + if (count($filename_list)) { + $this->mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); + $this->text_encoded = $this->attach_file($filename_list,$mimetype_list,$mimefilename_list); } } - function attach_file($filename,$mimetype,$mime_filename) + function attach_file($filename_list,$mimetype_list,$mimefilename_list) { - for ($i = 0; $i < count($filename); $i++) { - $encoded = $this->encode_file($filename[$i]); - if ($mime_filename[$i]) $filename[$i] = $mime_filename[$i]; - $out = $out . "--" . $this->mime_boundary . "\n"; - $out = $out . "Content-type: " . $mimetype[$i] . "; name=\"$filename[$i]\";\n"; - $out = $out . "Content-Transfer-Encoding: base64\n"; - $out = $out . "Content-disposition: attachment; filename=\"$filename[$i]\"\n\n"; - $out = $out . $encoded . "\n"; + for ($i = 0; $i < count($filename_list); $i++) { + $encoded = $this->encode_file($filename_list[$i]); + if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; + $out = $out . "--" . $this->mime_boundary . "\n"; + if (! $mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; } + $out = $out . "Content-type: " . $mimetype_list[$i] . "; name=\"$filename_list[$i]\";\n"; + $out = $out . "Content-Transfer-Encoding: base64\n"; + $out = $out . "Content-disposition: attachment; filename=\"$filename_list[$i]\"\n\n"; + $out = $out . $encoded . "\n"; } $out = $out . "--" . $this->mime_boundary . "--" . "\n"; return $out; @@ -84,9 +90,9 @@ class CMailFile return mail($this->addr_to,$this->subject,stripslashes($message),$headers); } - function write_body($msgtext, $filename) + function write_body($msgtext, $filename_list) { - if (strlen($filename)) + if (count($filename_list)) { $out = "--" . $this->mime_boundary . "\n"; $out = $out . "Content-Type: text/plain; charset=\"iso8859-15\"\n\n"; @@ -96,14 +102,14 @@ class CMailFile return $out; } - function write_mimeheaders($filename, $mime_filename) { + function write_mimeheaders($filename_list, $mimefilename_list) { $out = "MIME-version: 1.0\n"; $out = $out . "Content-type: multipart/mixed; "; $out = $out . "boundary=\"$this->mime_boundary\"\n"; $out = $out . "Content-transfer-encoding: 7BIT\n"; - for($i = 0; $i < count($filename); $i++) { - if ($mime_filename[$i]) $filename[$i] = $mime_filename[$i]; - $out = $out . "X-attachments: $filename[$i];\n\n"; + for($i = 0; $i < count($filename_list); $i++) { + if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; + $out = $out . "X-attachments: $filename_list[$i];\n\n"; } return $out; } @@ -112,7 +118,7 @@ class CMailFile { $out = "From: $addr_from\n"; if($addr_cc != "") - $out = $out . "Cc: $addr_cc\n"; + $out = $out . "Cc: $addr_cc\n"; $out = $out . "Reply-To: $addr_from\n"; $out = $out . "X-Mailer: Dolibarr version " . DOL_VERSION ."\n"; $out = $out . "X-Sender: $addr_from\n"; diff --git a/htdocs/notify.class.php b/htdocs/notify.class.php index b948b530ed8..df829b8442a 100644 --- a/htdocs/notify.class.php +++ b/htdocs/notify.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,7 +74,10 @@ class Notify $sendto, $replyto, $message, - $file, "application/pdf", $filename[sizeof($filename)-1]); + array($file), + array("application/pdf"), + array($filename[sizeof($filename)-1]) + ); if ( $mailfile->sendfile() ) {