diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index ee461ddb25f..baaac89b26f 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -177,11 +177,10 @@ if ($mil->fetch($_REQUEST["id"]) >= 0) print ''.$langs->trans("MailTitle").''.$mil->titre.''; - print ''.$langs->trans("MailFrom").''.htmlentities($mil->email_from).''; + print ''.$langs->trans("MailFrom").''.dol_print_email($mil->email_from,0,0,0,0,1).''; // Errors to - print ''.$langs->trans("MailErrorsTo").''.htmlentities($mil->email_errorsto); - if (! empty($mil->email_errorsto) && ! isValidEMail($mil->email_errorsto)) print img_warning($langs->trans("BadEMail")); + print ''.$langs->trans("MailErrorsTo").''.dol_print_email($mil->email_errorsto,0,0,0,0,1); print ''; // Status diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index b36de39b151..d31b8ea3808 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -354,22 +354,46 @@ if ($_POST["action"] == 'add') $_GET["action"]="create"; } +// Action update description of emailing +if ($_REQUEST["action"] == 'setdesc' || $_REQUEST["action"] == 'setfrom' || $_REQUEST["action"] == 'setreplyto' || $_REQUEST["action"] == 'seterrorsto') +{ + $mil = new Mailing($db); + $mil->fetch($_POST["id"]); + + if ($_REQUEST["action"] == 'setdesc') $mil->titre = trim($_REQUEST["desc"]); + if ($_REQUEST["action"] == 'setfrom') $mil->email_from = trim($_REQUEST["from"]); + if ($_REQUEST["action"] == 'setreplyto') $mil->email_replyto = trim($_REQUEST["replyto"]); + if ($_REQUEST["action"] == 'seterrorsto') $mil->email_errorsto = trim($_REQUEST["errorsto"]); + + if ($_REQUEST["action"] == 'setdesc' && empty($mil->titre)) $message.=($message?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); + if ($_REQUEST["action"] == 'setfrom' && empty($mil->email_from)) $message.=($message?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")); + + if (! $message) + { + if ($mil->update($user) >= 0) + { + Header("Location: fiche.php?id=".$mil->id); + exit; + } + $message=$mil->error; + } + + $message='
'.$message.'
'; + $_GET["action"]=""; + $_GET["id"]=$_REQUEST["id"]; +} + // Action update emailing if ($_POST["action"] == 'update' && empty($_POST["cancel"])) { $mil = new Mailing($db); + $mil->fetch($_POST["id"]); - $mil->id = $_POST["id"]; - $mil->email_from = trim($_POST["from"]); - $mil->email_replyto = trim($_POST["replyto"]); - $mil->email_errorsto = trim($_POST["errorsto"]); - $mil->titre = trim($_POST["titre"]); $mil->sujet = trim($_POST["sujet"]); $mil->body = trim($_POST["body"]); $mil->bgcolor = trim($_POST["bgcolor"]); $mil->bgimage = trim($_POST["bgimage"]); - if (! $mil->titre) $message.=($message?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle")); if (! $mil->sujet) $message.=($message?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic")); if (! $mil->body) $message.=($message?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody")); @@ -503,11 +527,13 @@ if ($_GET["action"] == 'create') if ($message) print "$message
"; print ''; - print ''; - print ''; print ''; print ''; + print '
'.$langs->trans("MailTitle").'
 
'.$langs->trans("MailFrom").'
'.$langs->trans("MailErrorsTo").'
'; + print '

'; + + print ''; print ''; print ''; - print ''; - print ''; + + // From + print ''; // Errors to - print ''; // Status @@ -630,16 +660,6 @@ else } print ''; - // Subject - print ''; - - // Message - print ''; - print ''; - print ''; - print '
'.$langs->trans("MailTopic").'
'.$langs->trans("BackgroundColorByDefault").''; $htmlother->select_color($_POST['bgcolor'],'bgcolor','new_mailing'); @@ -572,7 +598,6 @@ else { /* * Mailing en mode visu - * */ if ($_GET["action"] == 'sendall') { @@ -601,14 +626,19 @@ else print $html->showrefnav($mil,'id'); print '
'.$langs->trans("MailTitle").''.$mil->titre.'
'.$langs->trans("MailFrom").''.htmlentities($mil->email_from); - if (! isValidEMail($mil->email_from)) print img_warning($langs->trans("BadEMail")); + // Description + print '
'.$html->editfieldkey("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer).''; + print $html->editfieldval("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer); + print '
'.$html->editfieldkey("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer,'email').''; + print $html->editfieldval("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer,'email'); print '
'.$langs->trans("MailErrorsTo").''.htmlentities($mil->email_errorsto); - if (! empty($mil->email_errorsto) && ! isValidEMail($mil->email_errorsto)) print img_warning($langs->trans("BadEMail")); + print '
'.$html->editfieldkey("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer,'email').''; + print $html->editfieldval("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer,'email'); print '
'.$langs->trans("MailTopic").''.$mil->sujet.'
'.$langs->trans("MailMessage").''; - print dol_htmlentitiesbr($mil->body); - print '
'; print ""; @@ -656,6 +676,7 @@ else ); // Paiement incomplet. On demande si motif = escompte ou autre $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$mil->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$mil->ref),'confirm_clone',$formquestion,'yes'); + print '
'; } @@ -670,11 +691,12 @@ else $message.='
'; } - if ($message) print "$message
"; + if ($message) print $message; /* * Boutons d'action */ + if ($_GET["action"] == '') { print "\n\n
\n"; @@ -757,25 +779,99 @@ else print '
'; } + // Print mail content + print_fiche_titre($langs->trans("EMail"),'',''); + print ''; + + // Subject + print ''; + + // Mails +/* + $i=0; + while ($i < 4) + { + $i++; + $property='joined_file'.$i; + print ''; + } +*/ + + // Message + print ''; + print ''; + print ''; + + print '
'.$langs->trans("MailTopic").''.$mil->sujet.'
'.$langs->trans("MailFile").' '.$i.''.$mil->$property.'
'.$langs->trans("MailMessage").''; + print dol_htmlentitiesbr($mil->body); + print '
'; + print "
"; } else { /* * Mailing en mode edition */ - if ($message) print "$message
"; + + if ($message) print $message."
"; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Status + print ''; + + // Nb of distinct emails + print ''; + + print '
'.$langs->trans("Ref").''.$mil->id.'
'.$langs->trans("MailTitle").''.$mil->titre.'
'.$langs->trans("MailFrom").''.dol_print_email($mil->email_from,0,0,1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($mil->email_errorsto,0,0,1).'
'.$langs->trans("Status").''.$mil->getLibStatut(4).'
'; + print $langs->trans("TotalNbOfDistinctRecipients"); + print ''; + $nbemail = ($mil->nbemail?$mil->nbemail:''.$langs->trans("NoTargetYet").''); + if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) + { + $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); + print $html->textwithpicto($nbemail,$text,1,'warning'); + } + else + { + print $nbemail; + } + print '
'; + print "
"; + print '
'."\n"; print ''; print ''; print ''; + + // Print mail content + print_fiche_titre($langs->trans("EMail"),'',''); print ''; - print ''; - print ''; - print ''; - print ''; print ''; + + // Add joined files +/* $i=0; + while ($i < 4) + { + $i++; + $property='joined_file'.$i; + print ''; + print ''; + } +*/ + print ''; @@ -811,10 +907,11 @@ else print '   '; print ''; print ''; - print '
'.$langs->trans("Ref").''.$mil->id.'
'.$langs->trans("MailTitle").'
'.$langs->trans("MailFrom").'
'.$langs->trans("MailErrorsTo").'
'.$langs->trans("MailTopic").'
'.$langs->trans("MailFile").' '.$i.''; + print ''; + print ' '; + print ''; + print $mil->$property?'
'.$mil->$property:''; + print '
'.$langs->trans("BackgroundColorByDefault").''; $htmlother->select_color($mil->bgcolor,'bgcolor','edit_mailing'); print '
'; - print '
'; - print ""; + print ''; + + print ''; + print '
'; } } else diff --git a/htdocs/comm/mailing/mailing.class.php b/htdocs/comm/mailing/mailing.class.php index 6e6851cc8c4..bf73e40765c 100644 --- a/htdocs/comm/mailing/mailing.class.php +++ b/htdocs/comm/mailing/mailing.class.php @@ -52,6 +52,11 @@ class Mailing extends CommonObject var $email_replyto; var $email_errorsto; + var $joined_file1; + var $joined_file2; + var $joined_file3; + var $joined_file4; + var $user_creat; var $user_valid; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index acd58c5e81e..d75162526cb 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -62,9 +62,15 @@ class Form } /** - * \brief Output key field for an editable field + * \brief Output key field for an editable field + * \param text Text of label + * \param htmlname Name of select field + * \param preselected Preselected value for parameter + * \param paramkey Key of parameter (unique if there is several parameter to show) + * \param perm Permission to allow button to edit parameter + * \param typeofdata Type of data (string by default, email, ...) */ - function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm) + function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') { global $langs; $ret=''; @@ -77,9 +83,15 @@ class Form } /** - * \brief Output val field for an editable field + * \brief Output val field for an editable field + * \param text Text of label (not used in this function) + * \param htmlname Name of select field + * \param preselected Preselected value for parameter + * \param paramkey Key of parameter (unique if there is several parameter to show) + * \param perm Permission to allow button to edit parameter + * \param typeofdata Type of data (string by default, email, ...) */ - function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm) + function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') { global $langs; $ret=''; @@ -98,7 +110,11 @@ class Form $ret.=''."\n"; $ret.=''."\n"; } - else $ret.=$preselected; + else + { + if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); + else $ret.=$preselected; + } return $ret; } diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 5e262675c27..6de888e8aaa 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -9,7 +9,7 @@ MailCard=EMailing card MailTargets=Targets MailRecipients=Recipients MailRecipient=Recipient -MailTitle=Title +MailTitle=Description MailFrom=Sender MailErrorsTo=Errors to MailReply=Reply to diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 24a572c7097..21d7191e76e 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -9,7 +9,7 @@ AllEMailings=Tous les EMailings MailTargets=Destinataires MailRecipients=Destinataires MailRecipient=Destinataire -MailTitle=Titre +MailTitle=Description MailFrom=Émetteur MailErrorsTo=Erreurs à MailReply=Réponse à diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index be8b4bb5339..7847b545432 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -757,11 +757,12 @@ function dol_print_url($url,$target='_blank',$max=32) /** * \brief Show EMail link - * \param email EMail to show (only email without ) + * \param email EMail to show (only email, without ) * \param cid Id of contact if known * \param socid Id of third party if known * \param addlink 0=no link to create action * \param max Max number of characters to show + * \param showinvalid Show warning if syntax email is wrong * \return string HTML Link */ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=1) @@ -793,7 +794,14 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid= $newemail='
'.$newemail.'  '.$link.'
'; } } - + else + { + if ($showinvalid && ! isValidEmail($email)) + { + $langs->load("errors"); + $newemail.=img_warning($langs->trans("ErrorBadEMail",$email)); + } + } return $newemail; }