From d77a8b7697bd6ff1cc3b08e255a2df355e332252 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 10 Feb 2004 19:23:55 +0000 Subject: [PATCH] Ajout logs d'erreur lors de l'envoi de la facture --- htdocs/compta/facture.php | 70 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0ccc07b837a..6cc739139ec 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -254,52 +254,60 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] if ($action == 'send') { $fac = new Facture($db,"",$facid); - $fac->fetch($facid); - $soc = new Societe($db, $fac->socidp); - - $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; - - if (file_exists($file)) + if ( $fac->fetch($facid) ) { + $soc = new Societe($db, $fac->socidp); - $sendto = $soc->contact_get_email($HTTP_POST_VARS["destinataire"]); - $sendtoid = $HTTP_POST_VARS["destinataire"]; - - if (strlen($sendto)) + $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + + if (file_exists($file)) { + $sendto = $soc->contact_get_email($HTTP_POST_VARS["destinataire"]); + $sendtoid = $HTTP_POST_VARS["destinataire"]; - $subject = "Facture $fac->ref"; - $message = "Veuillez trouver ci-joint la facture $fac->ref\n\nCordialement\n\n"; - $filename = "$fac->ref.pdf"; - - $replyto = $HTTP_POST_VARS["replytoname"] . " <".$HTTP_POST_VARS["replytomail"] .">"; - - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$file, "application/pdf", $filename); - - if ( $mailfile->sendfile() ) - { - - $sendto = htmlentities($sendto); + if (strlen($sendto)) + { + $subject = "Facture $fac->ref"; + $message = "Veuillez trouver ci-joint la facture $fac->ref\n\nCordialement\n\n"; + $filename = $fac->ref.".pdf"; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea,fk_action,fk_soc,note,fk_facture, fk_contact,fk_user_author, label, percent) VALUES (now(), '9' ,'$fac->socidp' ,'Envoyée à $sendto','$fac->id','$sendtoid','$user->id', 'Envoi Facture par mail',100);"; - - if (! $db->query($sql) ) + $replyto = $HTTP_POST_VARS["replytoname"] . " <".$HTTP_POST_VARS["replytomail"] .">"; + + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$file, "application/pdf", $filename); + + if ( $mailfile->sendfile() ) { - print $db->error(); - print "

$sql

"; - } + + $sendto = htmlentities($sendto); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea,fk_action,fk_soc,note,fk_facture, fk_contact,fk_user_author, label, percent) VALUES (now(), '9' ,'$fac->socidp' ,'Envoyée à $sendto','$fac->id','$sendtoid','$user->id', 'Envoi Facture par mail',100);"; + + if (! $db->query($sql) ) + { + print $db->error(); + print "

$sql

"; + } + } + else + { + print "!! erreur d'envoi
$sendto
$replyto
$filename"; + } } else { - print "!! erreur d'envoi
$sendto
$replyto
$filename"; - } + dolibarr_syslog("Le mail du destinataire est vide"); + } } else { - print "Can't get email $sendto"; + dolibarr_syslog("Le fichier PDF n'existe pas"); } } + else + { + dolibarr_syslog("Impossible de lire la facture"); + } } /* *