Fix: Regression. Can add another file to proposal and invoices sending

This commit is contained in:
Laurent Destailleur 2008-07-11 16:14:57 +00:00
parent 9ce06c11d1
commit b5748c0fc5
7 changed files with 50 additions and 32 deletions

View File

@ -266,7 +266,7 @@ class ActionComm
$this->fk_propal = $obj->propalrowid; $this->fk_propal = $obj->propalrowid;
if ($this->fk_propal) if ($this->fk_propal)
{ {
$this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.'<a href="'. DOL_URL_ROOT . '/propal/fiche.php?rowid='.$this->fk_propal.'">'.$langs->trans("Propal").'</a>'; $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.'<a href="'. DOL_URL_ROOT . '/comm/propal.php?propalid='.$this->fk_propal.'">'.$langs->trans("Propal").'</a>';
$this->objet_url_type = 'propal'; $this->objet_url_type = 'propal';
} }

View File

@ -323,6 +323,7 @@ if ($_POST['addfile'])
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db); $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']); $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
} }
else else
@ -399,15 +400,14 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel'])
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode); $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
} }
$filepath[0] = $file; // Create form object
$filename[0] = $propal->ref.'.pdf'; include_once('../html.formmail.class.php');
$mimetype[0] = 'application/pdf'; $formmail = new FormMail($db);
if ($_FILES['addedfile']['tmp_name'])
{ $attachedfiles=$formmail->get_attached_files();
$filepath[1] = $_FILES['addedfile']['tmp_name']; $filepath = $attachedfiles['paths'];
$filename[1] = $_FILES['addedfile']['name']; $filename = $attachedfiles['names'];
$mimetype[1] = $_FILES['addedfile']['type']; $mimetype = $attachedfiles['mimes'];
}
// Envoi de la propal // Envoi de la propal
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
@ -445,8 +445,9 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel'])
} }
else else
{ {
// Renvoie sur la fiche // Redirect here
Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg)); // 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; exit;
} }
} }
@ -1782,9 +1783,10 @@ if ($_GET['propalid'] > 0)
$formmail->withto=$liste; $formmail->withto=$liste;
$formmail->withtocc=1; $formmail->withtocc=1;
$formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__');
$formmail->withfile=1; $formmail->withfile=2;
$formmail->withbody=1; $formmail->withbody=1;
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit['__PROPREF__']=$propal->ref; $formmail->substit['__PROPREF__']=$propal->ref;
// Tableau des parametres complementaires // Tableau des parametres complementaires

View File

@ -1084,15 +1084,14 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode); $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
} }
$filepath[0] = $file; // Create form object
$filename[0] = $fac->ref.'.pdf'; include_once('../html.formmail.class.php');
$mimetype[0] = 'application/pdf'; $formmail = new FormMail($db);
if ($_FILES['addedfile']['tmp_name'])
{ $attachedfiles=$formmail->get_attached_files();
$filepath[1] = $_FILES['addedfile']['tmp_name']; $filepath = $attachedfiles['paths'];
$filename[1] = $_FILES['addedfile']['name']; $filename = $attachedfiles['names'];
$mimetype[1] = $_FILES['addedfile']['type']; $mimetype = $attachedfiles['mimes'];
}
// Envoi de la facture // Envoi de la facture
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
@ -1130,7 +1129,8 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
} }
else 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)); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&mesg='.urlencode($mesg));
exit; exit;
} }
@ -3079,7 +3079,7 @@ else
$formmail->withtocc=1; $formmail->withtocc=1;
$formmail->withtoccc=$conf->global->FACTURE_EMAIL_USECCC; $formmail->withtoccc=$conf->global->FACTURE_EMAIL_USECCC;
$formmail->withtopic=$langs->trans('SendBillRef','__FACREF__'); $formmail->withtopic=$langs->trans('SendBillRef','__FACREF__');
$formmail->withfile=1; $formmail->withfile=2;
$formmail->withbody=1; $formmail->withbody=1;
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1; $formmail->withcancel=1;
@ -3142,7 +3142,7 @@ else
$formmail->withto=$liste; $formmail->withto=$liste;
$formmail->withtocc=1; $formmail->withtocc=1;
$formmail->withtopic=$langs->trans('SendReminderBillRef','__FACREF__'); $formmail->withtopic=$langs->trans('SendReminderBillRef','__FACREF__');
$formmail->withfile=1; $formmail->withfile=2;
$formmail->withbody=1; $formmail->withbody=1;
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1; $formmail->withcancel=1;

View File

@ -112,12 +112,12 @@ class FormFile
* \param modulepart propal=propal, facture=facture, ... * \param modulepart propal=propal, facture=facture, ...
* \param filename Sous rep à scanner (vide si filedir deja complet) * \param filename Sous rep à scanner (vide si filedir deja complet)
* \param filedir Repertoire à scanner * \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 genallowed Génération autorisée (1/0 ou array des formats)
* \param delallowed Suppression autorisée (1/0) * \param delallowed Suppression autorisée (1/0)
* \param modelselected Modele à pré-sélectionner par défaut * \param modelselected Modele à pré-sélectionner par défaut
* \param modelliste Tableau des modeles possibles * \param modelliste Tableau des modeles possibles
* \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini * \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) * \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 * \remarks Le fichier de facture détaillée est de la forme
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse

View File

@ -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 * \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 * \remarks this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -461,7 +461,7 @@ class Societe extends CommonObject
/** /**
* \brief Load a third party from database into memory * \brief Load a third party from database into memory
* \param socid Id third party to load * \param socid Id third party to load
* \param user User object * \param user User object (\deprecated)
* \return int >0 si ok, <0 si ko * \return int >0 si ok, <0 si ko
*/ */
function fetch($socid, $user=0) 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 * \brief Renvoie le nom d'une societe a partir d'un id
* \param id id de la soci<EFBFBD>t<EFBFBD> recherch<EFBFBD>e * \param id id company we search for name
* \return string Nom de la soci<EFBFBD>t<EFBFBD> * \return string Third party name
*/ */
function get_nom($id) function get_nom($id)
{ {