diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index eafc7cdfd24..709c2da6b94 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -21,6 +21,7 @@ */ require("./pre.inc.php3"); require("../facture.class.php3"); +require("../lib/CMailFile.class.php3"); llxHeader(); @@ -127,6 +128,58 @@ if ($action == 'add') $action = ''; } +/* + * + */ + +if ($action == 'send') +{ + $fac = new Facture($db,"",$facid); + $fac->fetch($facid); + + $soc = new Societe($db, $fac->socidp); + + $file = $conf->facture->outputdir . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + + if (file_exists($file)) + { + + $sendto = $soc->contact_get_email($HTTP_POST_VARS["destinataire"]); + + if (strlen($sendto)) + { + + $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() ) + { + + $sql = "INSERT INTO actioncomm (datea,fk_action,fk_soc,note,fk_facture) VALUES (now(), 9 ,$fac->socidp ,'Envoyée à $sendndto',$fac->id);"; + + if (! $db->query($sql) ) + { + print $db->error(); + print "
$sql
"; + } + } + else + { + print "!! erreur d'envoi| Date | "; - print 'Quantité | '; - print 'Montant | '; + print ' | Description | '; + print 'Quantité | '; + print 'Montant | '; print " | del | '; print 'edit | '; } + else + { + print ''; + } print ""; if ($action == 'editline' && $rowid == $objp->rowid) @@ -412,7 +471,7 @@ else print " |