From 92c7cf365940edd00c3a164dda071c2d5036cb9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Oct 2009 16:13:20 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20#27597=20:=20Impossibilit=E9=20d'aj?= =?UTF-8?q?outer=20un=20fichier=20attach=E9=20lors=20de=20l'envoi=20d'un?= =?UTF-8?q?=20document?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/mails.php | 2 +- htdocs/comm/mailing/fiche.php | 3 +- htdocs/comm/propal.php | 16 ++++---- htdocs/commande/fiche.php | 19 ++++----- htdocs/compta/dons/fiche.php | 2 +- htdocs/compta/facture.php | 19 ++++----- htdocs/compta/paiement/cheque/fiche.php | 2 +- htdocs/fourn/commande/fiche.php | 2 +- htdocs/html.formfile.class.php | 2 +- htdocs/html.formmail.class.php | 41 +++++++++++++++---- htdocs/lib/CMailFile.class.php | 13 +++--- htdocs/telephonie/client/facture.php | 53 ++++++++++++------------- 12 files changed, 96 insertions(+), 78 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 0e36a668e80..caea7e64f4c 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -67,7 +67,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update') if ($_POST['addfile'] || $_POST['addfilehtml']) { // Set tmp user directory - $vardir=$conf->users->dir_output."/".$user->id; + $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; if (! empty($_FILES['addedfile']['tmp_name'])) diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 19ab524faec..853bd789033 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -599,7 +599,7 @@ else // Status print ''.$langs->trans("Status").''.$mil->getLibStatut(4).''; - + // Nb of distinct emails print ''; print $langs->trans("TotalNbOfDistinctRecipients"); @@ -716,6 +716,7 @@ else $formmail->withfrom=0; $formmail->withto=$user->email?$user->email:1; $formmail->withtocc=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; $formmail->withtopic=0; $formmail->withtopicreadonly=1; $formmail->withfile=0; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index caea6c52d2a..1945596a615 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -366,7 +366,7 @@ if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer) if ($_POST['addfile']) { // Set tmp user directory - $vardir=$conf->users->dir_output."/".$user->id; + $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; if (! empty($_FILES['addedfile']['tmp_name'])) @@ -809,7 +809,7 @@ if ($_REQUEST['action'] == 'builddoc' && $user->rights->propale->creer) } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } @@ -1897,12 +1897,6 @@ if ($id > 0 || ! empty($ref)) print '
'; print_titre($langs->trans('SendPropalByMail')); - $liste[0]=" "; - foreach ($societe->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - // Create form object include_once('../html.formmail.class.php'); $formmail = new FormMail($db); @@ -1911,8 +1905,12 @@ if ($id > 0 || ! empty($ref)) $formmail->fromname = $user->fullname; $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=$liste; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$societe->id; $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 5b9a0544f54..a12bf89bdcf 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -668,7 +668,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } @@ -693,7 +693,7 @@ if ($_REQUEST['action'] == 'remove_file') if ($_POST['addfile']) { // Set tmp user directory - $vardir=$conf->users->dir_output."/".$user->id; + $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; if (! empty($_FILES['addedfile']['tmp_name'])) @@ -2103,15 +2103,6 @@ else print '
'; print_titre($langs->trans('SendOrderByMail')); - $soc = new Societe($db); - $soc->fetch($commande->socid); - - $liste[0]=" "; - foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - // Cree l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); @@ -2120,8 +2111,12 @@ else $formmail->fromname = $user->fullname; $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=$liste; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$soc->id; $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index cbb4738101f..bbfe116ee81 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -183,7 +183,7 @@ if ($_REQUEST['action'] == 'builddoc') } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?rowid='.$donation->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?rowid='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c708d0ab8cc..d09f6a360fa 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1117,7 +1117,7 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer) if ($_POST['addfile']) { // Set tmp user directory - $vardir=$conf->users->dir_output."/".$user->id; + $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; if (! empty($_FILES['addedfile']['tmp_name'])) @@ -1342,7 +1342,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } @@ -3510,12 +3510,6 @@ else print '
'; print_titre($langs->trans('SendBillByMail')); - $liste[0]=' '; - foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - // Cree l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); @@ -3524,9 +3518,12 @@ else $formmail->fromname = $user->fullname; $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=$liste; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$soc->id; $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->FACTURE_EMAIL_USECCC; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; $formmail->withtopic=$langs->transnoentities('SendBillRef','__FACREF__'); $formmail->withfile=2; $formmail->withbody=1; @@ -3534,7 +3531,7 @@ else $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__FACREF__']=$fac->ref; - // Tableau des param�tres compl�mentaires du post + // Tableau des parametres complementaires du post $formmail->param['action']='send'; $formmail->param['models']='facture_send'; $formmail->param['facid']=$fac->id; diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 679d43c74fc..124b36c3b62 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -149,7 +149,7 @@ if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque) } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 9762e5ffaac..961c1696012 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -417,7 +417,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc'); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 43bdb11974b..59f6a776bcf 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -291,7 +291,7 @@ class FormFile $buttonlabeltoshow=$buttonlabel; if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); - if (empty($noform)) print '
'; + if (empty($noform)) print ''; print ''; print ''; diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php index 838d7436e86..4e745944dca 100644 --- a/htdocs/html.formmail.class.php +++ b/htdocs/html.formmail.class.php @@ -101,7 +101,7 @@ class FormMail global $conf,$user; // Set tmp user directory - $vardir=$conf->users->dir_output."/".$user->id; + $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); @@ -285,11 +285,20 @@ class FormMail } else { - print "withto)?"30":"60")."\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_POST["sendto"])?$_POST["sendto"]:$this->withto) :"")."\">"; - if (is_array($this->withto)) + print "withto)?"30":"60")."\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"")."\">"; + if ($this->withtosocid > 0) { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } print " ".$langs->trans("or")." "; - print $form->selectarray("receiver", isset($_POST["receiver"])?$_POST["receiver"]:$this->withto); + //var_dump($_REQUEST);exit; + print $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0); } } print "\n"; @@ -308,10 +317,18 @@ class FormMail else { print "withtocc)?"30":"60")."\" name=\"sendtocc\" value=\"".((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") )."\">"; - if (is_array($this->withtocc)) + if ($this->withtoccsocid > 0) { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } print " ".$langs->trans("or")." "; - $form->select_array("receivercc", isset($_POST["receivercc"])?$_POST["receivercc"]:$this->withtocc); + $form->select_array("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0); } } print "\n"; @@ -330,10 +347,18 @@ class FormMail else { print "withtoccc)?"30":"60")."\" name=\"sendtoccc\" value=\"".((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") )."\">"; - if (is_array($this->withtoccc)) + if ($this->withtocccsocid > 0) { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } print " ".$langs->trans("or")." "; - $form->select_array("receiverccc", isset($_POST["receiverccc"])?$_POST["receiverccc"]:$this->withtoccc); + $form->select_array("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0); } } print "\n"; diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index dd3bb158983..e76a32c4f51 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -579,16 +579,19 @@ class CMailFile } /** - * \brief Permet d'encoder un fichier + * \brief Read a file on disk and return encoded content for emails * \param sourcefile - * \return <0 si erreur, fichier encode si ok + * \return <0 if KO, encoded string if OK */ function _encode_file($sourcefile) { - if (is_readable($sourcefile)) + $newsourcefile=utf8_check($sourcefile)?utf8_decode($sourcefile):$sourcefile; // is_readable and file_get_contents need ISO filename + + if (is_readable($newsourcefile)) { - $fd = fopen($sourcefile, "r"); - $contents = fread($fd, filesize($sourcefile)); + //$fd = fopen($newsourcefile, "rb"); + //$contents = fread($fd, filesize($newsourcefile)); + $contents = file_get_contents($newsourcefile); // Need PHP 4.3 $encoded = chunk_split(base64_encode($contents), 68, $this->eol); fclose($fd); return $encoded; diff --git a/htdocs/telephonie/client/facture.php b/htdocs/telephonie/client/facture.php index 1164a013e84..e8d26fe8b7c 100644 --- a/htdocs/telephonie/client/facture.php +++ b/htdocs/telephonie/client/facture.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2004 Éric Seigne + * Copyright (C) 2004 �ric Seigne * * 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 @@ -45,7 +45,7 @@ include_once DOL_DOCUMENT_ROOT."/actioncomm.class.php"; if ($_GET["socid"]) { $socid=$_GET["socid"]; } if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } -// Sécurité accés client +// S�curit� acc�s client if ($user->societe_id > 0) { $action = ''; @@ -70,12 +70,12 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') $soc = new Societe($db, $fac->socid); if ($_POST["sendto"]) { - // Le destinataire a été fourni via le champ libre + // Le destinataire a �t� fourni via le champ libre $sendto = $_POST["sendto"]; $sendtoid = 0; } elseif ($_POST["receiver"]) { - // Le destinataire a été fourni via la liste déroulante + // Le destinataire a �t� fourni via la liste d�roulante $sendto = $soc->contact_get_email($_POST["receiver"]); $sendtoid = $_POST["receiver"]; } @@ -88,9 +88,9 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') if ($_POST["action"] == 'send') { $subject = $langs->trans("Bill")." $fac->ref"; $actiontypeid=9; - $actionmsg ="Mail envoyé par ".$from." à ".$sendto.".\n"; + $actionmsg ="Mail envoy� par ".$from." � ".$sendto.".\n"; if ($message) { - $actionmsg.="Texte utilisé dans le corps du message:\n"; + $actionmsg.="Texte utilis� dans le corps du message:\n"; $actionmsg.=$message; } $actionmsg2="Envoi facture par mail"; @@ -98,9 +98,9 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') if ($_POST["action"] == 'relance') { $subject = "Relance facture $fac->ref"; $actiontypeid=9; - $actionmsg="Mail envoyé par ".$from." à ".$sendto.".\n"; + $actionmsg="Mail envoy� par ".$from." � ".$sendto.".\n"; if ($message) { - $actionmsg.="Texte utilisé dans le corps du message:\n"; + $actionmsg.="Texte utilis� dans le corps du message:\n"; $actionmsg.=$message; } $actionmsg2="Relance facture par mail"; @@ -158,7 +158,7 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') } else { - dol_syslog("Impossible de lire les données de la facture. Le fichier facture n'a peut-être pas été généré."); + dol_syslog("Impossible de lire les donn�es de la facture. Le fichier facture n'a peut-�tre pas �t� g�n�r�."); } } @@ -178,7 +178,7 @@ if ($_GET["facid"] > 0) if (!$soc->perm_read) { - print "Lecture non authorisée"; + print "Lecture non authoris�e"; } if ($soc->perm_read) @@ -212,7 +212,7 @@ if ($_GET["facid"] > 0) print ''; print ''.$soc->nom.''; - print "Conditions de réglement" . $fac->cond_reglement .""; + print "Conditions de r�glement" . $fac->cond_reglement .""; print ''.$langs->trans("Date").''; print "".dol_print_date($fac->date,"dayhourtext")."\n"; @@ -284,7 +284,7 @@ if ($_GET["facid"] > 0) if ($fac->paye == 0) { print "".$langs->trans("AlreadyPaid")." :".price($totalpaye)."".$langs->trans("Currency".$conf->monnaie)."\n"; - print "Facturé :".price($fac->total_ttc)."".$langs->trans("Currency".$conf->monnaie)."\n"; + print "Factur� :".price($fac->total_ttc)."".$langs->trans("Currency".$conf->monnaie)."\n"; $resteapayer = $fac->total_ttc - $totalpaye; @@ -493,8 +493,8 @@ if ($_GET["facid"] > 0) print '"; + print ""; $relativepathdetail = "${facref}/$file"; print ''; @@ -586,7 +586,7 @@ if ($_GET["facid"] > 0) print '
'; /* - * Documents générés - * Le fichier de facture détaillée est de la forme + * Documents g�n�r�s + * Le fichier de facture d�taill�e est de la forme * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse */ @@ -524,7 +524,7 @@ if ($_GET["facid"] > 0) { if (is_readable($dir.$file) && substr($file, -10) == 'detail.pdf') { - print "
Facture détaillée
Facture d�taill�e'.$file.''; /* - * Liste des actions propres à la facture + * Liste des actions propres � la facture */ $sql = "SELECT id, ".$db->pdate("a.datep")." as da, a.label, a.note"; $sql .= ", u.login"; @@ -642,25 +642,24 @@ if ($_GET["facid"] > 0) print '
'; print_titre($langs->trans("SendBillByMail")); - $liste[0]=" "; - foreach ($soc->contact_email_array() as $key=>$value) { - $liste[$key]=$value; - } - - // Créé l'objet formulaire mail + // Cree l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT."/html.formmail.class.php"); $formmail = new FormMail($db); $formmail->fromname = $user->fullname; $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=$liste; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$soc->id; $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans("SendBillRef","__FACREF__"); $formmail->withfile=1; $formmail->withbody=1; // Tableau des substitutions $formmail->substit["__FACREF__"]=$fac->ref; - // Tableau des paramètres complémentaires du post + // Tableau des param�tres compl�mentaires du post $formmail->param["action"]="send"; $formmail->param["models"]="facture_send"; $formmail->param["facid"]=$fac->id; @@ -688,7 +687,7 @@ if ($_GET["facid"] > 0) $liste[$key]=$value; } - // Créé l'objet formulaire mail + // Cr�� l'objet formulaire mail include_once("../html.formmail.class.php"); $formmail = new FormMail($db); $formmail->fromname = $user->fullname; @@ -701,7 +700,7 @@ if ($_GET["facid"] > 0) $formmail->withbody=1; // Tableau des substitutions $formmail->substit["__FACREF__"]=$fac->ref; - // Tableau des paramètres complémentaires + // Tableau des param�tres compl�mentaires $formmail->param["action"]="relance"; $formmail->param["models"]="facture_relance"; $formmail->param["facid"]=$fac->id; @@ -722,7 +721,7 @@ if ($_GET["facid"] > 0) } else { - /* Facture non trouvée */ + /* Facture non trouv�e */ print $langs->trans("ErrorBillNotFound",$_GET["facid"]); } }