New: Add list of attached files in email forms

This commit is contained in:
Laurent Destailleur 2008-05-23 19:43:28 +00:00
parent 9e54139305
commit 0a655c9370
13 changed files with 999 additions and 771 deletions

View File

@ -56,23 +56,65 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
exit; exit;
} }
// Action envoi test mailing
if ($_POST["action"] == 'send' && ! $_POST["cancel"])
{
$filepath = array();
$mimetype = array();
$filename = array();
/*
* Add file
*/
if ($_POST['addfile'])
{
// Set tmp user directory
$conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id;
$upload_dir = $conf->users->dir_tmp.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
// Echec transfert (fichier dépassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
}
}
$_GET["action"]='test';
}
/*
* Send mail
*/
if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel'])
{
$email_from = $conf->global->MAIN_MAIL_EMAIL_FROM; $email_from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$errors_to = $_POST["errorstomail"]; $errors_to = $_POST["errorstomail"];
$sendto = $_POST["sendto"]; $sendto = $_POST["sendto"];
$subject = $_POST['subject']; $subject = $_POST['subject'];
$body = $_POST['message']; $body = $_POST['message'];
if ($_FILES['addedfile']['tmp_name'])
// Get list of 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"]);
if (! empty($_FILES['addedfile']['tmp_name']))
{ {
$filepath[0] = $_FILES['addedfile']['tmp_name']; $listofpaths[] = $_FILES['addedfile']['tmp_name'];
$mimetype[0] = $_FILES['addedfile']['type']; $listofnames[] = $_FILES['addedfile']['name'];
$filename[0] = $_FILES['addedfile']['name']; $listofmimes[] = $_FILES['addedfile']['type'];
} }
if (! $sendto) if (! $sendto)
@ -91,7 +133,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$mailfile = new CMailFile($subject,$sendto,$email_from,$body, $mailfile = new CMailFile($subject,$sendto,$email_from,$body,
$filepath,$mimetype,$filename, $listofpaths,$listofmimes,$listofnames,
'', '', 0, $msgishtml,$errors_to); '', '', 0, $msgishtml,$errors_to);
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
@ -197,7 +239,7 @@ else
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
} }
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>'; print '</div>';
@ -240,10 +282,11 @@ else
$formmail->withtocc=1; $formmail->withtocc=1;
$formmail->withtopic=$langs->trans("Test"); $formmail->withtopic=$langs->trans("Test");
$formmail->withtopicreadonly=0; $formmail->withtopicreadonly=0;
$formmail->withfile=1; $formmail->withfile=2;
$formmail->withbody=$langs->trans("Test"); $formmail->withbody=$langs->trans("Test");
$formmail->withbodyreadonly=0; $formmail->withbodyreadonly=0;
$formmail->withcancel=1; $formmail->withcancel=1;
$formmail->withdeliveryreceipt=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit=$substitutionarrayfortest; $formmail->substit=$substitutionarrayfortest;
// Tableau des parametres complementaires du post // Tableau des parametres complementaires du post
@ -252,6 +295,12 @@ else
$formmail->param["mailid"]=$mil->id; $formmail->param["mailid"]=$mil->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/admin/mails.php"; $formmail->param["returnurl"]=DOL_URL_ROOT."/admin/mails.php";
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';

View File

@ -616,6 +616,7 @@ else
$formmail->withbody=0; $formmail->withbody=0;
$formmail->withbodyreadonly=1; $formmail->withbodyreadonly=1;
$formmail->withcancel=1; $formmail->withcancel=1;
$formmail->withdeliveryreceipt=0;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit=$substitutionarrayfortest; $formmail->substit=$substitutionarrayfortest;
// Tableau des paramètres complémentaires du post // Tableau des paramètres complémentaires du post
@ -624,6 +625,12 @@ else
$formmail->param["mailid"]=$mil->id; $formmail->param["mailid"]=$mil->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';

View File

@ -293,16 +293,53 @@ if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer)
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
// prevent browser refresh from closing proposal several times // prevent browser refresh from closing proposal several times
if ($propal->statut==1) { if ($propal->statut==1)
{
$propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); $propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']);
} }
} }
} }
/* /*
* Envoi de la propale par mail * Add file
*/ */
if ($_POST['action'] == 'send') if ($_POST['addfile'])
{
// Set tmp user directory
$conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id;
$upload_dir = $conf->users->dir_tmp.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
// Echec transfert (fichier dépassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
}
}
$_GET["action"]='presend';
}
/*
* Send mail
*/
if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel'])
{ {
$langs->load('mails'); $langs->load('mails');
@ -1571,6 +1608,8 @@ if ($_GET['propalid'] > 0)
/* /*
* Boutons Actions * Boutons Actions
*/ */
if ($_GET['action'] != 'presend')
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($_GET['action'] != 'statut' && $_GET['action'] <> 'editline') if ($_GET['action'] != 'statut' && $_GET['action'] <> 'editline')
@ -1605,7 +1644,7 @@ if ($_GET['propalid'] > 0)
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
if (file_exists($file)) if (file_exists($file))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&amp;action=presend">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
} }
@ -1648,8 +1687,10 @@ if ($_GET['propalid'] > 0)
print '</div>'; print '</div>';
print "<br>\n"; print "<br>\n";
}
if ($_GET['action'] != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
@ -1709,6 +1750,7 @@ if ($_GET['propalid'] > 0)
$somethingshown=$formactions->showactions($propal,'propal',$socid); $somethingshown=$formactions->showactions($propal,'propal',$socid);
print '</td></tr></table>'; print '</td></tr></table>';
}
/* /*
@ -1717,6 +1759,9 @@ if ($_GET['propalid'] > 0)
*/ */
if ($_GET['action'] == 'presend') if ($_GET['action'] == 'presend')
{ {
$ref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf';
print '<br>'; print '<br>';
print_titre($langs->trans('SendPropalByMail')); print_titre($langs->trans('SendPropalByMail'));
@ -1748,6 +1793,13 @@ if ($_GET['propalid'] > 0)
$formmail->param['propalid']=$propal->id; $formmail->param['propalid']=$propal->id;
$formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,$propal->ref.'.pdf','application/pdf');
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';

View File

@ -525,7 +525,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post
// Sauvegarde le dernier modele choisi pour generer un document // Sauvegarde le dernier modele choisi pour generer un document
$commande = new Commande($db, 0, $_REQUEST['id']); $commande = new Commande($db, 0, $_REQUEST['id']);
$commande->fetch($_REQUEST['id']); $result=$commande->fetch($_REQUEST['id']);
if ($_REQUEST['model']) if ($_REQUEST['model'])
{ {
$commande->setDocModel($user, $_REQUEST['model']); $commande->setDocModel($user, $_REQUEST['model']);
@ -565,17 +565,53 @@ if ($_REQUEST['action'] == 'remove_file')
} }
/* /*
* Envoi de la commande par mail * Add file
*/ */
if ($_POST['action'] == 'send') if ($_POST['addfile'])
{
// Set tmp user directory
$conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id;
$upload_dir = $conf->users->dir_tmp.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
// Echec transfert (fichier dépassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
}
}
$_GET["action"]='presend';
}
/*
* Send mail
*/
if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel'])
{ {
$langs->load('mails'); $langs->load('mails');
$commande= new Commande($db); $commande= new Commande($db);
if ( $commande->fetch($_POST['orderid']) ) $result=$commande->fetch($_POST['orderid']);
if ($result)
{ {
$orderref = sanitize_string($commande->ref); $ref = sanitize_string($commande->ref);
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (is_readable($file)) if (is_readable($file))
{ {
@ -627,19 +663,23 @@ if ($_POST['action'] == 'send')
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode); $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
} }
$filepath[0] = $file; // Get list of attached files
$filename[0] = $commande->ref.'.pdf'; $listofpaths=array();
$mimetype[0] = 'application/pdf'; $listofnames=array();
if ($_FILES['addedfile']['tmp_name']) $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"]);
if (! empty($_FILES['addedfile']['tmp_name']))
{ {
$filepath[1] = $_FILES['addedfile']['tmp_name']; $listofpaths[] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name']; $listofnames[] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type']; $listofmimes[] = $_FILES['addedfile']['type'];
} }
// Envoi de la commande // Send mail
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); $mailfile = new CMailFile($subject,$sendto,$from,$message,$listofpaths,$listofmimes,$listofnames,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error) if ($mailfile->error)
{ {
$mesg='<div class="error">'.$mailfile->error.'</div>'; $mesg='<div class="error">'.$mailfile->error.'</div>';
@ -699,6 +739,7 @@ if ($_POST['action'] == 'send')
{ {
$langs->load("other"); $langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; $mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
$_GET["action"]='presend';
dolibarr_syslog('Recipient email is empty'); dolibarr_syslog('Recipient email is empty');
} }
} }
@ -1679,9 +1720,12 @@ else
print '</table>'; print '</table>';
print '</div>'; print '</div>';
/* /*
* Boutons actions * Boutons actions
*/ */
if ($_GET['action'] != 'presend')
{
if ($user->societe_id == 0 && $_GET['action'] <> 'editline') if ($user->societe_id == 0 && $_GET['action'] <> 'editline')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -1730,7 +1774,7 @@ else
$file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf'; $file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
if (file_exists($file)) if (file_exists($file))
{ {
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=presend">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
} }
} }
@ -1812,8 +1856,11 @@ else
print '</div>'; print '</div>';
} }
print '<br>'; print '<br>';
}
if ($_GET['action'] != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
@ -1879,7 +1926,7 @@ else
$somethingshown=$formactions->showactions($commande,'order',$socid); $somethingshown=$formactions->showactions($commande,'order',$socid);
print '</td></tr></table>'; print '</td></tr></table>';
}
/* /*
@ -1888,24 +1935,8 @@ else
*/ */
if ($_GET['action'] == 'presend') if ($_GET['action'] == 'presend')
{ {
$orderref = sanitize_string($commande->ref); $ref = sanitize_string($commande->ref);
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// Construit PDF si non existant
if (! is_readable($file))
{
if ($_REQUEST['lang_id'])
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
$result=commande_pdf_create($db, $_REQUEST['id'], '', $_REQUEST['model'], $outputlangs);
if ($result <= 0)
{
dolibarr_print_error($db,$result);
exit;
}
}
print '<br>'; print '<br>';
print_titre($langs->trans('SendOrderByMail')); print_titre($langs->trans('SendOrderByMail'));
@ -1920,7 +1951,7 @@ else
} }
// Cree l'objet formulaire mail // Cree l'objet formulaire mail
include_once('../html.formmail.class.php'); include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db); $formmail = new FormMail($db);
$formmail->fromtype = 'user'; $formmail->fromtype = 'user';
$formmail->fromid = $user->id; $formmail->fromid = $user->id;
@ -1933,6 +1964,7 @@ else
$formmail->withfile=1; $formmail->withfile=1;
$formmail->withbody=1; $formmail->withbody=1;
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit['__ORDERREF__']=$commande->ref; $formmail->substit['__ORDERREF__']=$commande->ref;
// Tableau des parametres complementaires // Tableau des parametres complementaires
@ -1941,6 +1973,14 @@ else
$formmail->param['orderid']=$commande->id; $formmail->param['orderid']=$commande->id;
$formmail->param['returnurl']=DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,$ref.'.pdf','application/pdf');
}
// Show form
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';

View File

@ -950,17 +950,53 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer)
} }
/* /*
* Action envoi de mail * Add file
*/ */
if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['cancel']) if ($_POST['addfile'])
{
// Set tmp user directory
$conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id;
$upload_dir = $conf->users->dir_tmp.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
// Echec transfert (fichier dépassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
}
}
$_GET["action"]='presend';
}
/*
* Send mail
*/
if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['addfile'] && ! $_POST['cancel'])
{ {
$langs->load('mails'); $langs->load('mails');
$fac = new Facture($db,'',$_POST['facid']); $fac = new Facture($db,'',$_POST['facid']);
if ( $fac->fetch($_POST['facid']) ) $result=$fac->fetch($_POST['facid']);
if ($result)
{ {
$facref = sanitize_string($fac->ref); $ref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (is_readable($file)) if (is_readable($file))
{ {
@ -2687,6 +2723,8 @@ else
/* /*
* Boutons actions * Boutons actions
*/ */
if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend')
{
if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -2731,7 +2769,7 @@ else
} }
else else
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=presend">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
} }
@ -2744,7 +2782,7 @@ else
} }
else else
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=prerelance">'.$langs->trans('SendRemindByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=prerelance&amp;mode=init">'.$langs->trans('SendRemindByMail').'</a>';
} }
} }
@ -2826,7 +2864,11 @@ else
print '</div>'; print '</div>';
} }
}
if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
@ -2962,15 +3004,15 @@ else
$somethingshown=$formactions->showactions($fac,'invoice',$socid); $somethingshown=$formactions->showactions($fac,'invoice',$socid);
print '</td></tr></table>'; print '</td></tr></table>';
}
/* /*
* Affiche formulaire mail * Affiche formulaire mail
*/ */
if ($_GET['action'] == 'presend') if ($_GET['action'] == 'presend')
{ {
$facref = sanitize_string($fac->ref); $ref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// Construit PDF si non existant // Construit PDF si non existant
if (! is_readable($file)) if (! is_readable($file))
@ -3021,6 +3063,13 @@ else
$formmail->param['facid']=$fac->id; $formmail->param['facid']=$fac->id;
$formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,$ref.'.pdf','application/pdf');
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';
@ -3028,8 +3077,8 @@ else
if ($_GET['action'] == 'prerelance') if ($_GET['action'] == 'prerelance')
{ {
$facref = sanitize_string($fac->ref); $ref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// Construit PDF si non existant // Construit PDF si non existant
if (! is_readable($file)) if (! is_readable($file))
@ -3068,6 +3117,7 @@ else
$formmail->withfile=1; $formmail->withfile=1;
$formmail->withbody=1; $formmail->withbody=1;
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit['__FACREF__']=$fac->ref; $formmail->substit['__FACREF__']=$fac->ref;
// Tableau des paramètres complémentaires // Tableau des paramètres complémentaires
@ -3076,6 +3126,13 @@ else
$formmail->param['facid']=$fac->id; $formmail->param['facid']=$fac->id;
$formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,$ref.'.pdf','application/pdf');
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';

View File

@ -436,69 +436,6 @@ class FormFile
} }
/**
* \brief Show list of documents in a directory
* \param upload_dir Dir to scan
* \param object Object on which document is linked to
* \param modulepart Value for modulepart used by download wrapper
* \return int <0 if KO, nb of files shown if OK
*/
function list_of_documents2($upload_dir,$object,$modulepart)
{
global $user, $conf, $langs;
global $bc;
// List of documents
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Document').'</td>';
print '<td align="right">'.$langs->trans('Size').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
if ($handle)
{
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file)
&& $file != '.'
&& $file != '..'
&& $file != 'CVS'
&& ! eregi('\.meta$',$file)
)
{
// Define relative path used to store the file
$morepath=$object->ref.'/';
if ($modulepart == 'facture_fournisseur') $morepath=get_exdir($object->id,2).$morepath;
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
print img_mime($file).' ';
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.urlencode($morepath.$file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans('bytes').'</td>';
print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
print "</td></tr>\n";
}
}
closedir($handle);
}
print '</table>';
}
} }
?> ?>

View File

@ -32,7 +32,6 @@ require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php");
\remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs
\remarks $formmail->show_form() affiche le formulaire \remarks $formmail->show_form() affiche le formulaire
*/ */
class FormMail class FormMail
{ {
var $db; var $db;
@ -49,7 +48,7 @@ class FormMail
var $withto; var $withto;
var $withtocc; var $withtocc;
var $withtopic; var $withtopic;
var $withfile; var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
var $withbody; var $withbody;
var $withfromreadonly; var $withfromreadonly;
@ -95,9 +94,51 @@ class FormMail
return 1; return 1;
} }
/**
* Clear list of attached files (store in SECTION array)
*/
function clear_attached_files()
{
global $conf,$user;
/* $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id;
$upload_dir = $conf->users->dir_tmp.'/temp';
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
unset($_SESSION["listofpaths"]);
unset($_SESSION["listofnames"]);
unset($_SESSION["listofmimes"]);
}
/**
* Add a file into the list of attached files (stored in SECTION array)
*
* @param unknown_type $path
* @param unknown_type $file
* @param unknown_type $type
*/
function add_attached_files($path,$file,$type)
{
$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"]);
if (! in_array($file,$listofnames))
{
$listofpaths[]=$path;
$listofnames[]=$file;
$listofmimes[]=$type;
$_SESSION["listofpaths"]=join(';',$listofpaths);
$_SESSION["listofnames"]=join(';',$listofnames);
$_SESSION["listofmimes"]=join(';',$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
*/ */
function show_form() function show_form()
{ {
@ -106,6 +147,15 @@ class FormMail
$langs->load("other"); $langs->load("other");
$langs->load("mails"); $langs->load("mails");
// Define list of 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"]);
$form=new Form($DB); $form=new Form($DB);
print "\n<!-- Debut form mail -->\n"; print "\n<!-- Debut form mail -->\n";
@ -294,13 +344,32 @@ class FormMail
print "</td></tr>\n"; print "</td></tr>\n";
} }
// Si fichier joint // Attached files
if ($this->withfile) if ($this->withfile)
{ {
print "<tr>"; print "<tr>";
print "<td width=\"180\">".$langs->trans("MailFile")."</td>"; print '<td width="180">'.$langs->trans("MailFile")."</td>";
print "<td>"; print "<td>";
//print '<table class="nobordernopadding" width="100%"><tr><td>';
if (sizeof($listofpaths))
{
foreach($listofpaths as $key => $val)
{
print img_mime($listofnames[$key]).' '.$listofnames[$key].'<br>';
}
}
else
{
print $langs->trans("NoAttachedFiles").'<br>';
}
if ($this->withfile == 2) // Can add other files
{
//print '<td><td align="right">';
print "<input type=\"file\" class=\"flat\" name=\"addedfile\" value=\"".$langs->trans("Upload")."\"/>"; print "<input type=\"file\" class=\"flat\" name=\"addedfile\" value=\"".$langs->trans("Upload")."\"/>";
print ' ';
print '<input type="submit" class="button" name="addfile" value="'.$langs->trans("MailingAddFile").'">';
//print '</td></tr></table>';
}
print "</td></tr>\n"; print "</td></tr>\n";
} }

View File

@ -16,7 +16,7 @@ MailCC=Copy to
MailCCC=Cached copy to MailCCC=Cached copy to
MailTopic=EMail topic MailTopic=EMail topic
MailText=Message MailText=Message
MailFile=Attach a file MailFile=Attached files
MailMessage=EMail body MailMessage=EMail body
ListOfEMailings=List of emailings ListOfEMailings=List of emailings
NewMailing=New emailing NewMailing=New emailing
@ -54,6 +54,8 @@ RemoveRecipient=Remove recipient
CommonSubstitutions=Common substitutions CommonSubstitutions=Common substitutions
YouCanAddYourOwnPredefindedListHere=To create your email selector module, see htdocs/includes/modules/mailings/README. YouCanAddYourOwnPredefindedListHere=To create your email selector module, see htdocs/includes/modules/mailings/README.
EMailTestSubstitutionReplacedByGenericValues=When using test mode, substitutions variables are replaced by generic values EMailTestSubstitutionReplacedByGenericValues=When using test mode, substitutions variables are replaced by generic values
MailingAddFile=Attach this file
NoAttachedFiles=No attached files
# Libelle des modules de liste de destinataires mailing # Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Unique contacts of all third parties MailingModuleDescContactCompanies=Unique contacts of all third parties

View File

@ -15,7 +15,7 @@ MailTo=Destinatario(s)
MailCC=Copia a MailCC=Copia a
MailTopic=Asunto del e-mail MailTopic=Asunto del e-mail
MailText=Mensaje MailText=Mensaje
MailFile=Adjuntar un archivo MailFile=Archivo
MailMessage=Mensaje del e-mail MailMessage=Mensaje del e-mail
ListOfEMailings=Listado de mailings ListOfEMailings=Listado de mailings
NewMailing=Nuevo mailing NewMailing=Nuevo mailing

View File

@ -16,7 +16,7 @@ MailCC=Copie
MailCCC=Copie cachée à MailCCC=Copie cachée à
MailTopic=Sujet du mail MailTopic=Sujet du mail
MailText=Message MailText=Message
MailFile=Joindre un fichier MailFile=Fichiers joints
MailMessage=Message du mail MailMessage=Message du mail
ListOfEMailings=Liste des mailings ListOfEMailings=Liste des mailings
NewMailing=Nouveau mailing NewMailing=Nouveau mailing
@ -54,6 +54,8 @@ RemoveRecipient=Supprime destinataire
CommonSubstitutions=Substitutions communes CommonSubstitutions=Substitutions communes
YouCanAddYourOwnPredefindedListHere=Pour créer votre module sélection mails, voir htdocs/includes/modules/mailings/README. YouCanAddYourOwnPredefindedListHere=Pour créer votre module sélection mails, voir htdocs/includes/modules/mailings/README.
EMailTestSubstitutionReplacedByGenericValues=En mode test, les variables de substitution sont remplacées par des valeurs génériques EMailTestSubstitutionReplacedByGenericValues=En mode test, les variables de substitution sont remplacées par des valeurs génériques
MailingAddFile=Joindre ce fichier
NoAttachedFiles=Aucun fichier joint
# Libelle des modules de liste de destinataires mailing # Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...) MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...)

View File

@ -404,10 +404,11 @@ if ($user->admin)
$user->rights->user->self->password=1; $user->rights->user->self->password=1;
} }
/** /*
* Overwrite configs global par configs perso * Overwrite configs global par configs perso
* ------------------------------------------ * ------------------------------------------
*/ */
// Set liste_limite
if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) // Can be 0 if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) // Can be 0
{ {
$conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;

View File

@ -474,14 +474,14 @@ if ($_GET["facid"] > 0)
// Envoyer // Envoyer
if ($fac->statut == 1 && $user->rights->facture->envoyer) if ($fac->statut == 1 && $user->rights->facture->envoyer)
{ {
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=presend\">".$langs->trans("Send")."</a>\n"; print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=presend&amp;mode=init\">".$langs->trans("Send")."</a>\n";
} }
// Envoyer une relance // Envoyer une relance
/* /*
if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer) if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer)
{ {
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=prerelance\">".$langs->trans("SendRemind")."</a>\n"; print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=prerelance&amp;mode=init\">".$langs->trans("SendRemind")."</a>\n";
} }
*/ */
@ -665,6 +665,12 @@ if ($_GET["facid"] > 0)
$formmail->param["facid"]=$fac->id; $formmail->param["facid"]=$fac->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/telephonie/client/facture.php?facid=$fac->id"; $formmail->param["returnurl"]=DOL_URL_ROOT."/telephonie/client/facture.php?facid=$fac->id";
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';
@ -700,6 +706,12 @@ if ($_GET["facid"] > 0)
$formmail->param["facid"]=$fac->id; $formmail->param["facid"]=$fac->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id"; $formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id";
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form(); $formmail->show_form();
print '<br>'; print '<br>';