mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
EMailing edit page more user firendly
This commit is contained in:
parent
40814719ee
commit
846ed3688e
|
|
@ -1,6 +1,6 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@uers.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -177,11 +177,10 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
|
|||
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from).'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($mil->email_from,0,0,0,0,1).'</td></tr>';
|
||||
|
||||
// Errors to
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.htmlentities($mil->email_errorsto);
|
||||
if (! empty($mil->email_errorsto) && ! isValidEMail($mil->email_errorsto)) print img_warning($langs->trans("BadEMail"));
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($mil->email_errorsto,0,0,0,0,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
|
|
|
|||
|
|
@ -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?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle"));
|
||||
if ($_REQUEST["action"] == 'setfrom' && empty($mil->email_from)) $message.=($message?'<br>':'').$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='<div class="error">'.$message.'</div>';
|
||||
$_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?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle"));
|
||||
if (! $mil->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
|
||||
if (! $mil->body) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
|
||||
|
||||
|
|
@ -503,11 +527,13 @@ if ($_GET["action"] == 'create')
|
|||
if ($message) print "$message<br>";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTitle").'</td><td><input class="flat" name="titre" size="40" value="'.$_POST['titre'].'"></td></tr>';
|
||||
print '<tr><td colspan="2"> </td></tr>';
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailFrom").'</td><td><input class="flat" name="from" size="40" value="'.$conf->global->MAILING_EMAIL_FROM.'"></td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td><input class="flat" name="errorsto" size="40" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</br><br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTopic").'</td><td><input class="flat" name="sujet" size="60" value="'.$_POST['sujet'].'"></td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
|
||||
$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 '</td></tr>';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from);
|
||||
if (! isValidEMail($mil->email_from)) print img_warning($langs->trans("BadEMail"));
|
||||
// Description
|
||||
print '<tr><td>'.$html->editfieldkey("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer).'</td><td colspan="3">';
|
||||
print $html->editfieldval("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer);
|
||||
print '</td></tr>';
|
||||
|
||||
// From
|
||||
print '<tr><td>'.$html->editfieldkey("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer,'email').'</td><td colspan="3">';
|
||||
print $html->editfieldval("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer,'email');
|
||||
print '</td></tr>';
|
||||
|
||||
// Errors to
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.htmlentities($mil->email_errorsto);
|
||||
if (! empty($mil->email_errorsto) && ! isValidEMail($mil->email_errorsto)) print img_warning($langs->trans("BadEMail"));
|
||||
print '<tr><td>'.$html->editfieldkey("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer,'email').'</td><td colspan="3">';
|
||||
print $html->editfieldval("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer,'email');
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
|
|
@ -630,16 +660,6 @@ else
|
|||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Subject
|
||||
print '<tr><td>'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
||||
|
||||
// Message
|
||||
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>';
|
||||
print '<td colspan="3" bgcolor="'.($mil->bgcolor?$mil->bgcolor:'white').'">';
|
||||
print dol_htmlentitiesbr($mil->body);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print "</div>";
|
||||
|
|
@ -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 '<br>';
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -670,11 +691,12 @@ else
|
|||
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$_GET["id"].'</textarea>';
|
||||
}
|
||||
|
||||
if ($message) print "$message<br>";
|
||||
if ($message) print $message;
|
||||
|
||||
/*
|
||||
* Boutons d'action
|
||||
*/
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
print "\n\n<div class=\"tabsAction\">\n";
|
||||
|
|
@ -757,25 +779,99 @@ else
|
|||
print '<br>';
|
||||
}
|
||||
|
||||
// Print mail content
|
||||
print_fiche_titre($langs->trans("EMail"),'','');
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Subject
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
||||
|
||||
// Mails
|
||||
/*
|
||||
$i=0;
|
||||
while ($i < 4)
|
||||
{
|
||||
$i++;
|
||||
$property='joined_file'.$i;
|
||||
print '<tr><td>'.$langs->trans("MailFile").' '.$i.'</td><td colspan="3">'.$mil->$property.'</td></tr>';
|
||||
}
|
||||
*/
|
||||
|
||||
// Message
|
||||
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>';
|
||||
print '<td colspan="3" bgcolor="'.($mil->bgcolor?$mil->bgcolor:'white').'">';
|
||||
print dol_htmlentitiesbr($mil->body);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print "<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Mailing en mode edition
|
||||
*/
|
||||
if ($message) print "$message<br>";
|
||||
|
||||
if ($message) print $message."<br>";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($mil->email_from,0,0,1).'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($mil->email_errorsto,0,0,1).'</td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Nb of distinct emails
|
||||
print '<tr><td width="25%">';
|
||||
print $langs->trans("TotalNbOfDistinctRecipients");
|
||||
print '</td><td colspan="3">';
|
||||
$nbemail = ($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>');
|
||||
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 '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print "</div>";
|
||||
|
||||
|
||||
print '<form name="edit_mailing" action="fiche.php" method="post">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$mil->id.'">';
|
||||
|
||||
// Print mail content
|
||||
print_fiche_titre($langs->trans("EMail"),'','');
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>';
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTitle").'</td><td colspan="3"><input class="flat" type="text" size=40 name="titre" value="'.$mil->titre.'"></td></tr>';
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailFrom").'</td><td colspan="3"><input class="flat" type="text" size=40 name="from" value="'.$mil->email_from.'"></td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3"><input class="flat" type="text" size=40 name="errorsto" value="'.$mil->email_errorsto.'"></td></tr>';
|
||||
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTopic").'</td><td colspan="3"><input class="flat" type="text" size=60 name="sujet" value="'.$mil->sujet.'"></td></tr>';
|
||||
|
||||
// Add joined files
|
||||
/* $i=0;
|
||||
while ($i < 4)
|
||||
{
|
||||
$i++;
|
||||
$property='joined_file'.$i;
|
||||
print '<tr><td>'.$langs->trans("MailFile").' '.$i.'</td>';
|
||||
print '<td colspan="3">';
|
||||
print '<input type="file" class="flat" name="addedfile" value="'.$langs->trans("Upload").'"/>';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'">';
|
||||
print $mil->$property?'<br>'.$mil->$property:'';
|
||||
print '</td></tr>';
|
||||
}
|
||||
*/
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
|
||||
$htmlother->select_color($mil->bgcolor,'bgcolor','edit_mailing');
|
||||
print '</td></tr>';
|
||||
|
|
@ -811,10 +907,11 @@ else
|
|||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">';
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
print "</div>";
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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.='</tr></table>'."\n";
|
||||
$ret.='</form>'."\n";
|
||||
}
|
||||
else $ret.=$preselected;
|
||||
else
|
||||
{
|
||||
if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1);
|
||||
else $ret.=$preselected;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 à
|
||||
|
|
|
|||
|
|
@ -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 <Name of recipient>)
|
||||
* \param email EMail to show (only email, without <Name of recipient>)
|
||||
* \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='<table class="nobordernopadding"><tr><td>'.$newemail.' </td><td> '.$link.'</td></tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($showinvalid && ! isValidEmail($email))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$newemail.=img_warning($langs->trans("ErrorBadEMail",$email));
|
||||
}
|
||||
}
|
||||
return $newemail;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user