La fonction d'envoi de facture par mails ne fonctionnait plus. Tous les appels CMailFile fournissent maintenant un tableau de la liste des fichiers joindre. Si il n'y en a qu'un, il s'agira d'un tableau d'un seul lment.
This commit is contained in:
parent
2dde860775
commit
aa3127f3b8
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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() )
|
||||
{
|
||||
|
||||
@ -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 '<p><table id="actions" width="100%"><tr>';
|
||||
|
||||
// Supprimer
|
||||
if ($fac->statut == 0 && $user->rights->facture->supprimer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=delete\">Supprimer</a></td>";
|
||||
}
|
||||
elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=presend\">Envoyer</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\">-</td>";
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement)
|
||||
{
|
||||
print '<td align="center" width="20%">';
|
||||
print '<a href="paiement.php?facid='.$fac->id.'&action=create">Emettre un paiement</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0)
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=payed\">Classer 'Payée'</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
}
|
||||
elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=prerelance\">Envoyer une relance</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
print '<td align="center" width="20%"><a href="facture/fiche-rec.php?facid='.$fac->id.'&action=create">Récurrente</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
|
||||
// Valider
|
||||
if ($fac->statut == 0 && $fac->total_ht > 0)
|
||||
{
|
||||
if ($user->rights->facture->valider)
|
||||
@ -997,8 +952,10 @@ else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
}
|
||||
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 '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
}
|
||||
|
||||
// Envoyer
|
||||
if ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=presend\">Envoyer</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\">-</td>";
|
||||
}
|
||||
|
||||
// Envoyer une relance
|
||||
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=prerelance\">Envoyer une relance</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
|
||||
// Emettre paiement
|
||||
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement)
|
||||
{
|
||||
print '<td align="center" width="20%">';
|
||||
print '<a href="paiement.php?facid='.$fac->id.'&action=create">Emettre un paiement</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
|
||||
// Classer 'payé'
|
||||
if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0)
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$fac->id&action=payed\">Classer 'Payée'</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
}
|
||||
|
||||
// Récurrente
|
||||
if (! defined("FACTURE_NORECURENTE")) { // Possibilité de désactiver les factures récurrentes
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
print '<td align="center" width="20%"><a href="facture/fiche-rec.php?facid='.$fac->id.'&action=create">Récurrente</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</tr></table>";
|
||||
}
|
||||
print "<p>\n";
|
||||
@ -1121,14 +1135,14 @@ else
|
||||
|
||||
print "<p><b>Envoyer la facture par mail</b>";
|
||||
print "<table cellspacing=0 border=1 cellpadding=3>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail </td></tr>";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td><td>$replytomail </td></tr>";
|
||||
print '<tr><td>Destinataire</td><td colspan="5">';
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_array("destinataire",$soc->contact_email_array());
|
||||
|
||||
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$fac->email\"></td></tr>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail </td></tr>";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td><td>$replytomail </td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print "<input type=\"submit\" value=\"Envoyer\"></form>";
|
||||
@ -1149,15 +1163,15 @@ else
|
||||
|
||||
print_titre("Envoyer une relance");
|
||||
print "<table cellspacing=0 border=1 cellpadding=3>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>\n";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td><td>$replytomail</td></tr>\n";
|
||||
print '<tr><td>Destinataire</td><td colspan="5">';
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_array("destinataire",$soc->contact_email_array());
|
||||
|
||||
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$fac->email\"></td></tr>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
|
||||
print "<td>$replytomail</td></tr></table>";
|
||||
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$fac->email\"></td></tr>\n";
|
||||
print "</table>";
|
||||
|
||||
print "<input type=\"submit\" value=\"Envoyer\"></form>";
|
||||
}
|
||||
|
||||
@ -737,9 +737,10 @@ class Facture
|
||||
$sendto,
|
||||
$replyto,
|
||||
$message,
|
||||
$file,
|
||||
"application/pdf",
|
||||
$filename);
|
||||
array($file),
|
||||
array("application/pdf"),
|
||||
array($filename)
|
||||
);
|
||||
|
||||
if ( $mailfile->sendfile() )
|
||||
{
|
||||
|
||||
@ -22,6 +22,10 @@ to chunk_split
|
||||
Éric Seigne <eric.seigne@ryxeo.com> 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";
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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() )
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user