quand on expdie une propale on peut maintenant saisir le texte qu'on veut, mettre qqn en copie et rajouter un fichier attach

This commit is contained in:
erics 2004-01-08 11:43:33 +00:00
parent 2ca06fd64f
commit 4263a59cab
9 changed files with 62 additions and 38 deletions

View File

@ -22,6 +22,9 @@
require("./pre.inc.php");
$user->getrights('facture');
print "user " . $user->rights->facture->lire . " !";
if (!$user->rights->facture->lire)
accessforbidden();

View File

@ -170,7 +170,7 @@ if ($action == 'create')
*/
$sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p ";
$sql .= " WHERE envente = 1";
$sql .= " ORDER BY p.nbvente DESC LIMIT 20";
$sql .= " ORDER BY ref DESC";
if ( $db->query($sql) )
{
$opt = "<option value=\"0\" SELECTED></option>";

View File

@ -431,8 +431,8 @@ if ($_GET["propalid"])
if ($obj->statut == 0 && $user->rights->propale->creer)
{
$sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p WHERE p.envente=1 ORDER BY p.nbvente DESC LIMIT 20";
// RyXéo on a ORDER BY p.ref et pas de limit
if ( $db->query($sql) )
{
$opt = "<option value=\"0\" SELECTED></option>";
@ -607,14 +607,15 @@ if ($_GET["propalid"])
{
$subject = "Notre proposition commerciale $obj->ref";
$message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n";
$filepath = $file ;
$filename = "$obj->ref.pdf";
$mimetype = "application/pdf";
$filepath[0] = $file ;
$filename[0] = "$obj->ref.pdf";
$mimetype[0] = "application/pdf";
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
$replyto = "$replytoname <$replytomail>";
$mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename);
$mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename,$sendtocc);
if (! $mailfile->sendfile() )
{
@ -750,17 +751,24 @@ if ($_GET["propalid"])
$from_name = $user->fullname ; //$conf->propal->fromtoname;
$from_mail = $user->email; //conf->propal->fromtomail;
print "<form method=\"post\" action=\"$PHP_SELF?propalid=$propal->id&amp;action=send\">\n";
$message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n";
print "<form method=\"post\" ENCTYPE=\"multipart/form-data\" action=\"$PHP_SELF?propalid=$propal->id&amp;action=send\">\n";
print "<input type=\"hidden\" name=\"replytoname\" value=\"$replytoname\">\n";
print "<input type=\"hidden\" name=\"replytomail\" value=\"$replytomail\">\n";
print '<input type="hidden" name="max_file_size" value="2000000">';
print_titre("Envoyer la propale par mail");
print "<table cellspacing=0 border=1 cellpadding=3>";
print "<tr><td>Destinataire</td><td colspan=\"5\">$obj->firstname $obj->name</td>";
print "<td><input size=\"30\" name=\"sendto\" value=\"$obj->email\"></td></tr>";
print "<tr><td>Destinataire</td>";
print "<td colspan=\"6\" align=\"right\"><input size=\"50\" name=\"sendto\" value=\"" . ucfirst(strtolower($obj->firstname)) . " " . ucfirst(strtolower($obj->name)) . " <$obj->email>\"></td></tr>";
print "<tr><td>Copie à</td>";
print "<td colspan=\"6\" align=\"right\"><input size=\"50\" name=\"sendtocc\"></td></tr>";
print "<tr><td>Expediteur</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>";
print "<tr><td valign=\"top\">Joindre un fichier en plus de la propale<br>(conditions générales de ventes ...)</td><td colspan=\"6\"><input type=\"file\" name=\"addedfile\" size=\"40\" maxlength=\"80\"></td></tr>";
print "<tr><td valign=\"top\">Message</td><td colspan=\"6\"><textarea rows=\"5\" cols=\"40\" name=\"message\">$message</textarea></td></tr>";
print "</table>";
print "<input type=\"submit\" value=\"Envoyer\">";

View File

@ -288,7 +288,7 @@ class Commande
}
$sql = "INSERT INTO llx_commandedet (fk_commande, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
$sql .= " (".$this->id.", $p_product_id,". $p_qty.",". $price.",".$p_tva_tx.",'".$p_desc."',$remise_percent, $subprice) ; ";
$sql .= " ('".$this->id."', '$p_product_id','". $p_qty."','". $price."','".$p_tva_tx."',''".addslashes($p_desc)."','$remise_percent', '$subprice') ; ";
if ($this->db->query($sql) )
{
@ -345,7 +345,7 @@ class Commande
}
$sql = "INSERT INTO llx_commandedet (fk_commande,label,description,price,qty,tva_tx, fk_product, remise_percent, subprice, remise)";
$sql .= " VALUES ($this->id, '$desc','$desc', $price, $qty, $txtva, $fk_product, $remise_percent, $subprice, $remise) ;";
$sql .= " VALUES ($this->id, '" . addslashes($desc) . "','" . addslashes($desc) . "', $price, $qty, $txtva, $fk_product, $remise_percent, $subprice, $remise) ;";
if ( $this->db->query( $sql) )
{

View File

@ -257,7 +257,7 @@ class Expedition
}
$sql = "INSERT INTO llx_commandedet (fk_commande, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
$sql .= " (".$this->id.", $p_product_id,". $p_qty.",". $price.",".$p_tva_tx.",'".$p_desc."',$remise_percent, $subprice) ; ";
$sql .= " (".$this->id.", $p_product_id,". $p_qty.",". $price.",".$p_tva_tx.",'". addslashes($p_desc) ."',$remise_percent, $subprice) ; ";
if ($this->db->query($sql) )
{

View File

@ -36,7 +36,7 @@ function facture_get_num($objsoc=0)
}
$num++;
// return "FA" . $date . substr("000".$num, strlen("000".$num)-4,4);
return $date . $num;
return "F" . $date . $num;
}
?>

View File

@ -154,7 +154,7 @@ Class pdf_propale_rouge
$pdf->MultiCell(42, $tab2_lh, "Remise HT", 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(42, $tab2_lh, "Total HT aprés remise", 0, 'R', 0);
$pdf->MultiCell(42, $tab2_lh, "Total HT après remise", 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0);

View File

@ -18,40 +18,47 @@ to chunk_split
*/
/* Note: if you don't have base64_encode on your sytem it will not work */
/*
Éric Seigne <eric.seigne@ryxeo.com> 2004.01.08
- ajout de la gestion du Cc
- ajout de l'expédition de plusieurs fichiers
*/
// simple class that encapsulates mail() with addition of mime file attachment.
class CMailFile
{
var $subject;
var $addr_to;
var $addr_cc;
var $text_body;
var $text_encoded;
var $mime_headers;
var $mime_boundary = "--==================_846811060==_";
var $smtp_headers;
function CMailFile($subject,$to,$from,$msg,$filename,$mimetype = "application/octet-stream", $mime_filename = false)
function CMailFile($subject,$to,$from,$msg,$filename,$mimetype = "application/octet-stream", $mime_filename = false, $addr_cc = "")
{
$this->subject = $subject;
$this->addr_to = $to;
$this->smtp_headers = $this->write_smtpheaders($from);
$this->text_body = $this->write_body($msg, $filename);
if (strlen($filename))
{
$this->text_encoded = $this->attach_file($filename,$mimetype,$mime_filename);
$this->mime_headers = $this->write_mimeheaders($filename, $mime_filename);
}
$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);
}
}
function attach_file($filename,$mimetype,$mime_filename)
{
$encoded = $this->encode_file($filename);
if ($mime_filename) $filename = $mime_filename;
$out = "--" . $this->mime_boundary . "\n";
$out = $out . "Content-type: " . $mimetype . "; name=\"$filename\";\n";
$out = $out . "Content-Transfer-Encoding: base64\n";
$out = $out . "Content-disposition: attachment; filename=\"$filename\"\n\n";
$out = $out . $encoded . "\n";
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";
}
$out = $out . "--" . $this->mime_boundary . "--" . "\n";
return $out;
// added -- to notify email client attachment is done
@ -59,21 +66,22 @@ class CMailFile
function encode_file($sourcefile)
{
// print "<pre> on encode $sourcefile </pre>\n";
if (is_readable($sourcefile))
{
$fd = fopen($sourcefile, "r");
$contents = fread($fd, filesize($sourcefile));
$encoded = my_chunk_split(base64_encode($contents));
fclose($fd);
fclose($fd);
}
return $encoded;
}
function sendfile()
{
$headers = $this->smtp_headers . $this->mime_headers;
$headers .= $this->smtp_headers . $this->mime_headers;
$message = $this->text_body . $this->text_encoded;
return mail($this->addr_to,$this->subject,$message,$headers);
return mail($this->addr_to,$this->subject,stripslashes($message),$headers);
}
function write_body($msgtext, $filename)
@ -89,18 +97,22 @@ class CMailFile
}
function write_mimeheaders($filename, $mime_filename) {
if ($mime_filename) $filename = $mime_filename;
$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";
$out = $out . "X-attachments: $filename;\n\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";
}
return $out;
}
function write_smtpheaders($addr_from)
function write_smtpheaders($addr_from,$addr_cc)
{
$out = "From: $addr_from\n";
if($addr_cc != "")
$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";

View File

@ -148,6 +148,7 @@ class DoliDb {
Function query($query, $limit="", $offset="")
{
$query = trim($query);
print "<p>$query</p>\n";
$this->results = mysql_query($query, $this->db);
return $this->results;
}