Fix bug #27597 : Impossibilit d'ajouter un fichier attach lors de l'envoi d'un document

This commit is contained in:
Laurent Destailleur 2009-10-14 16:13:20 +00:00
parent b924c9e103
commit 92c7cf3659
12 changed files with 96 additions and 78 deletions

View File

@ -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']))

View File

@ -599,7 +599,7 @@ else
// Status
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>';
// Nb of distinct emails
print '<tr><td width="25%">';
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;

View File

@ -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 '<br>';
print_titre($langs->trans('SendPropalByMail'));
$liste[0]="&nbsp;";
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;

View File

@ -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 '<br>';
print_titre($langs->trans('SendOrderByMail'));
$soc = new Societe($db);
$soc->fetch($commande->socid);
$liste[0]="&nbsp;";
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;

View File

@ -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;
}
}

View File

@ -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 '<br>';
print_titre($langs->trans('SendBillByMail'));
$liste[0]='&nbsp;';
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<EFBFBD>tres compl<70>mentaires du post
// Tableau des parametres complementaires du post
$formmail->param['action']='send';
$formmail->param['models']='facture_send';
$formmail->param['facid']=$fac->id;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -291,7 +291,7 @@ class FormFile
$buttonlabeltoshow=$buttonlabel;
if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate');
if (empty($noform)) print '<form action="'.$urlsource.'#builddoc" method="post">';
if (empty($noform)) print '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" method="post">';
print '<input type="hidden" name="action" value="builddoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -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 "<input size=\"".(is_array($this->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 "<input size=\"".(is_array($this->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]='&nbsp;';
$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 "</td></tr>\n";
@ -308,10 +317,18 @@ class FormMail
else
{
print "<input size=\"".(is_array($this->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]='&nbsp;';
$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 "</td></tr>\n";
@ -330,10 +347,18 @@ class FormMail
else
{
print "<input size=\"".(is_array($this->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]='&nbsp;';
$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 "</td></tr>\n";

View File

@ -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;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com>
*
* 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<EFBFBD>curit<EFBFBD> acc<63>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 <EFBFBD>t<EFBFBD> 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 <EFBFBD>t<EFBFBD> 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<EFBFBD> par ".$from." <20> ".$sendto.".\n";
if ($message) {
$actionmsg.="Texte utilisé dans le corps du message:\n";
$actionmsg.="Texte utilis<EFBFBD> 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<EFBFBD> par ".$from." <20> ".$sendto.".\n";
if ($message) {
$actionmsg.="Texte utilisé dans le corps du message:\n";
$actionmsg.="Texte utilis<EFBFBD> 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<EFBFBD>es de la facture. Le fichier facture n'a peut-<2D>tre pas <20>t<EFBFBD> g<>n<EFBFBD>r<EFBFBD>.");
}
}
@ -178,7 +178,7 @@ if ($_GET["facid"] > 0)
if (!$soc->perm_read)
{
print "Lecture non authorisée";
print "Lecture non authoris<EFBFBD>e";
}
if ($soc->perm_read)
@ -212,7 +212,7 @@ if ($_GET["facid"] > 0)
print '<td colspan="3">';
print '<b><a href="fiche.php?id='.$soc->id.'">'.$soc->nom.'</a></b></td>';
print "<td>Conditions de réglement</td><td>" . $fac->cond_reglement ."</td></tr>";
print "<td>Conditions de r<EFBFBD>glement</td><td>" . $fac->cond_reglement ."</td></tr>";
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"3\">".dol_print_date($fac->date,"dayhourtext")."</td>\n";
@ -284,7 +284,7 @@ if ($_GET["facid"] > 0)
if ($fac->paye == 0)
{
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Facturé :</td><td align=\"right\" style=\"border: 1px solid;\">".price($fac->total_ttc)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Factur<EFBFBD> :</td><td align=\"right\" style=\"border: 1px solid;\">".price($fac->total_ttc)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
$resteapayer = $fac->total_ttc - $totalpaye;
@ -493,8 +493,8 @@ if ($_GET["facid"] > 0)
print '<table width="100%"><tr><td width="50%" valign="top">';
/*
* Documents générés
* Le fichier de facture détaillée est de la forme
* Documents g<EFBFBD>n<EFBFBD>r<EFBFBD>s
* Le fichier de facture d<EFBFBD>taill<EFBFBD>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 "<tr $bc[$var]><td>Facture détaillée</td>";
print "<tr $bc[$var]><td>Facture d<EFBFBD>taill<EFBFBD>e</td>";
$relativepathdetail = "${facref}/$file";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$file.'</a></td>';
@ -586,7 +586,7 @@ if ($_GET["facid"] > 0)
print '</td><td valign="top" width="50%">';
/*
* Liste des actions propres à la facture
* Liste des actions propres <EFBFBD> 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 '<br>';
print_titre($langs->trans("SendBillByMail"));
$liste[0]="&nbsp;";
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<EFBFBD>tres compl<70>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<EFBFBD><EFBFBD> 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<EFBFBD>tres compl<70>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<EFBFBD>e */
print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
}
}