diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 065b1236b99..c3348bd1b33 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -266,7 +266,7 @@ class ActionComm $this->fk_propal = $obj->propalrowid; if ($this->fk_propal) { - $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.''.$langs->trans("Propal").''; + $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.''.$langs->trans("Propal").''; $this->objet_url_type = 'propal'; } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 79b01b0ca88..5a068639343 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -323,6 +323,7 @@ if ($_POST['addfile']) include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); + // Add file in list of files in session $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); } else @@ -399,16 +400,15 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } - $filepath[0] = $file; - $filename[0] = $propal->ref.'.pdf'; - $mimetype[0] = 'application/pdf'; - if ($_FILES['addedfile']['tmp_name']) - { - $filepath[1] = $_FILES['addedfile']['tmp_name']; - $filename[1] = $_FILES['addedfile']['name']; - $mimetype[1] = $_FILES['addedfile']['type']; - } + // Create form object + include_once('../html.formmail.class.php'); + $formmail = new FormMail($db); + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + // Envoi de la propal require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); @@ -445,8 +445,9 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) } else { - // Renvoie sur la fiche - Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg)); + // Redirect here + // This avoid sending mail twice if going out and then back to page + Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg)); exit; } } @@ -1782,9 +1783,10 @@ if ($_GET['propalid'] > 0) $formmail->withto=$liste; $formmail->withtocc=1; $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); - $formmail->withfile=1; + $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__PROPREF__']=$propal->ref; // Tableau des parametres complementaires diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3192267797e..47bf66330e3 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1084,16 +1084,15 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } - $filepath[0] = $file; - $filename[0] = $fac->ref.'.pdf'; - $mimetype[0] = 'application/pdf'; - if ($_FILES['addedfile']['tmp_name']) - { - $filepath[1] = $_FILES['addedfile']['tmp_name']; - $filename[1] = $_FILES['addedfile']['name']; - $mimetype[1] = $_FILES['addedfile']['type']; - } + // Create form object + include_once('../html.formmail.class.php'); + $formmail = new FormMail($db); + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + // Envoi de la facture require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); @@ -1130,7 +1129,8 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a } else { - // Renvoie sur la fiche + // Redirect here + // This avoid sending mail twice if going out and then back to page Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&mesg='.urlencode($mesg)); exit; } @@ -3079,7 +3079,7 @@ else $formmail->withtocc=1; $formmail->withtoccc=$conf->global->FACTURE_EMAIL_USECCC; $formmail->withtopic=$langs->trans('SendBillRef','__FACREF__'); - $formmail->withfile=1; + $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; @@ -3142,7 +3142,7 @@ else $formmail->withto=$liste; $formmail->withtocc=1; $formmail->withtopic=$langs->trans('SendReminderBillRef','__FACREF__'); - $formmail->withfile=1; + $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 838b2c76cbb..3bc2bed24bb 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -112,12 +112,12 @@ class FormFile * \param modulepart propal=propal, facture=facture, ... * \param filename Sous rep à scanner (vide si filedir deja complet) * \param filedir Repertoire à scanner - * \param urlsource Url page origine + * \param urlsource Url page origine (pour retour) * \param genallowed Génération autorisée (1/0 ou array des formats) * \param delallowed Suppression autorisée (1/0) * \param modelselected Modele à pré-sélectionner par défaut - * \param modelliste Tableau des modeles possibles - * \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini + * \param modelliste Tableau des modeles possibles + * \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini * \param iconPDF N'affiche que l'icone PDF avec le lien (1/0) * \remarks Le fichier de facture détaillée est de la forme * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php index 5900c801539..5c5cfb04a57 100644 --- a/htdocs/html.formmail.class.php +++ b/htdocs/html.formmail.class.php @@ -136,6 +136,22 @@ class FormMail } } + /** + * Return list of attached files (stored in SECTION array) + * + * @return unknown_type $type + */ + function get_attached_files() + { + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=split(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=split(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=split(';',$_SESSION["listofmimes"]); + return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); + } + /** * \brief Affiche la partie de formulaire pour saisie d'un mail en fonction des propriétés * \remarks this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 614eee16cb0..53a09245070 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * 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 diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index a514fff288e..3ca88c482e4 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -461,7 +461,7 @@ class Societe extends CommonObject /** * \brief Load a third party from database into memory * \param socid Id third party to load - * \param user User object + * \param user User object (\deprecated) * \return int >0 si ok, <0 si ko */ function fetch($socid, $user=0) @@ -1154,8 +1154,8 @@ class Societe extends CommonObject /** * \brief Renvoie le nom d'une societe a partir d'un id - * \param id id de la soci�t� recherch�e - * \return string Nom de la soci�t� + * \param id id company we search for name + * \return string Third party name */ function get_nom($id) {