From 4263a59cab94e1bff0602f19d00910abc27c03c2 Mon Sep 17 00:00:00 2001 From: erics Date: Thu, 8 Jan 2004 11:43:33 +0000 Subject: [PATCH] =?UTF-8?q?quand=20on=20exp=E9die=20une=20propale=20on=20p?= =?UTF-8?q?eut=20maintenant=20saisir=20le=20texte=20qu'on=20veut,=20mettre?= =?UTF-8?q?=20qqn=20en=20copie=20et=20rajouter=20un=20fichier=20attach=E9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/system/update.php | 3 + htdocs/comm/addpropal.php | 2 +- htdocs/comm/propal.php | 28 ++++++---- htdocs/commande/commande.class.php | 4 +- htdocs/expedition/expedition.class.php | 2 +- .../facture/jupiter/jupiter.modules.php | 2 +- .../propale/pdf_propale_rouge.modules.php | 2 +- htdocs/lib/CMailFile.class.php | 56 +++++++++++-------- htdocs/lib/mysql.lib.php | 1 + 9 files changed, 62 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/system/update.php b/htdocs/admin/system/update.php index a759b02ed29..ba7071ecff3 100644 --- a/htdocs/admin/system/update.php +++ b/htdocs/admin/system/update.php @@ -22,6 +22,9 @@ require("./pre.inc.php"); $user->getrights('facture'); + +print "user " . $user->rights->facture->lire . " !"; + if (!$user->rights->facture->lire) accessforbidden(); diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index e57948556cd..5b346fb6f17 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -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 = ""; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4b5b50e1f15..10c4cb489c8 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -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 = ""; @@ -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 "
id&action=send\">\n"; + $message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n"; + + print "id&action=send\">\n"; print "\n"; print "\n"; + print ''; print_titre("Envoyer la propale par mail"); print ""; - print ""; - print ""; + print ""; + print ""; + print ""; + print ""; print ""; print ""; print ""; + print ""; + print ""; print "
Destinataire$obj->firstname $obj->nameemail\">
Destinatairefirstname)) . " " . ucfirst(strtolower($obj->name)) . " <$obj->email>\">
Copie à
Expediteur$from_name$from_mail
Reply-to$replytoname$replytomail
Joindre un fichier en plus de la propale
(conditions générales de ventes ...)
Message
"; print ""; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 775b1366a58..41cfeed5b31 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -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) ) { diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 43038eae140..4d8df17e629 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -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) ) { diff --git a/htdocs/includes/modules/facture/jupiter/jupiter.modules.php b/htdocs/includes/modules/facture/jupiter/jupiter.modules.php index 3c90531fb8d..0f73a8fe314 100644 --- a/htdocs/includes/modules/facture/jupiter/jupiter.modules.php +++ b/htdocs/includes/modules/facture/jupiter/jupiter.modules.php @@ -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; } ?> diff --git a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php index f5d94e761c6..e2bf27390c4 100644 --- a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php @@ -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); diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index 0ec7c1c0a05..a1bb546de30 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -18,40 +18,47 @@ to chunk_split */ /* Note: if you don't have base64_encode on your sytem it will not work */ +/* + Éric Seigne 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 "
 on encode $sourcefile 
\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"; diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index 5dfa2a6b598..03aeb7e785d 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -148,6 +148,7 @@ class DoliDb { Function query($query, $limit="", $offset="") { $query = trim($query); + print "

$query

\n"; $this->results = mysql_query($query, $this->db); return $this->results; }