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

View File

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

View File

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

View File

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

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

View File

@ -1,6 +1,6 @@
<?php
/* 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
* 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
* \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<EFBFBD>t<EFBFBD> recherch<EFBFBD>e
* \return string Nom de la soci<EFBFBD>t<EFBFBD>
* \param id id company we search for name
* \return string Third party name
*/
function get_nom($id)
{