Amlioration prsentation statut d'envoi de chaque destinataire
This commit is contained in:
parent
8b4f01195b
commit
281a5a8c2b
@ -134,7 +134,7 @@ llxHeader("","",$langs->trans("MailCard"));
|
||||
$mil = new Mailing($db);
|
||||
|
||||
$html = new Form($db);
|
||||
if ($mil->fetch($_REQUEST["id"]) == 0)
|
||||
if ($mil->fetch($_REQUEST["id"]) >= 0)
|
||||
{
|
||||
|
||||
$h=0;
|
||||
@ -148,7 +148,7 @@ if ($mil->fetch($_REQUEST["id"]) == 0)
|
||||
$h++;
|
||||
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
@ -309,7 +309,8 @@ if ($mil->fetch($_REQUEST["id"]) == 0)
|
||||
print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.prenom",$addu,"","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$addu,"","",$sortfield);
|
||||
print '<td align="center"> </td>';
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$addu,'','align="center"',$sortfield);
|
||||
|
||||
// Date
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
print '<td> </td>';
|
||||
@ -318,6 +319,10 @@ if ($mil->fetch($_REQUEST["id"]) == 0)
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
||||
}
|
||||
|
||||
// Statut
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$addu,'','align="right"',$sortfield);
|
||||
|
||||
print '</tr>';
|
||||
|
||||
// Ligne des champs de filtres
|
||||
@ -353,19 +358,19 @@ if ($mil->fetch($_REQUEST["id"]) == 0)
|
||||
print '<td>'.$obj->email.'</td>';
|
||||
print '<td>'.$obj->url.'</td>';
|
||||
|
||||
// Statut
|
||||
// Statut pour l'email destinataire (Attentioon != statut du mailing)
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("MailingStatusNotSent").'</td>';
|
||||
print '<td><a href="cibles.php?action=delete&id='.$mil->id.'&rowid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveRecipient")).'</td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="right">'.$langs->trans("MailingStatusNotSent").' <a href="cibles.php?action=delete&id='.$mil->id.'&rowid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveRecipient")).'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">';
|
||||
if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error();
|
||||
if ($obj->statut==1) print $langs->trans("MailingStatusSent");
|
||||
print '</td>';
|
||||
print '<td align="center">'.$obj->date_envoi.'</td>';
|
||||
print '<td align="right">';
|
||||
if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error();
|
||||
if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -54,33 +54,17 @@ if ($_GET["action"] == 'sendall')
|
||||
if ($_POST["action"] == 'send')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
|
||||
$mil->id = $_POST["mailid"];
|
||||
$mil->fromname = $_POST["fromname"];
|
||||
$mil->frommail = $_POST["frommail"];
|
||||
$result=$mil->fetch($_POST["mailid"]);
|
||||
|
||||
$mil->sendto = $_POST["sendto"];
|
||||
$mil->titre = $_POST["titre"];
|
||||
$mil->sujet = $_POST["subject"];
|
||||
$mil->body = $_POST["message"];
|
||||
|
||||
if (! $mil->sendto)
|
||||
{
|
||||
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'</div>';
|
||||
}
|
||||
if (! $mil->sujet)
|
||||
{
|
||||
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic")).'</div>';
|
||||
}
|
||||
if (! $mil->body)
|
||||
{
|
||||
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("MailMessage")).'</div>';
|
||||
}
|
||||
if ($mil->sendto && $mil->sujet && $mil->body)
|
||||
if ($mil->sendto)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
|
||||
|
||||
$sendto = $mil->sendto;
|
||||
$from = $mil->fromname." <".$mil->frommail.">";
|
||||
$arr_file = array();
|
||||
$arr_mime = array();
|
||||
$arr_name = array();
|
||||
@ -90,15 +74,14 @@ if ($_POST["action"] == 'send')
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) $msgishtml=1;
|
||||
if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
|
||||
|
||||
$mailfile = new CMailFile($mil->sujet,$sendto,$from,$mil->body,
|
||||
$mailfile = new CMailFile($mil->sujet,$mil->sendto,$mil->email_from,$mil->body,
|
||||
$arr_file,$arr_mime,$arr_name,
|
||||
'', '', 0, $msgishtml);
|
||||
|
||||
$result=$mailfile->sendfile();
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$from,$sendto).'</div>';
|
||||
$message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$mil->email_from,$mil->sendto).'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -159,50 +142,53 @@ if ($_POST["action"] == 'update')
|
||||
// Action confirmation validation
|
||||
if ($_POST["action"] == 'confirm_valide')
|
||||
{
|
||||
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$mil->valid($user);
|
||||
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
$mil = new Mailing($db);
|
||||
|
||||
if ($mil->fetch($_GET["id"]) >= 0)
|
||||
{
|
||||
$mil->valid($user);
|
||||
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_approve')
|
||||
{
|
||||
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$mil = new Mailing($db);
|
||||
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$mil->approve($user);
|
||||
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
$mil = new Mailing($db);
|
||||
|
||||
if ($mil->fetch($_GET["id"]) >= 0)
|
||||
{
|
||||
$mil->approve($user);
|
||||
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
// Action confirmation suppression
|
||||
@ -279,7 +265,7 @@ else
|
||||
{
|
||||
$html = new Form($db);
|
||||
|
||||
if ($mil->fetch($_GET["id"]) == 0)
|
||||
if ($mil->fetch($_GET["id"]) >= 0)
|
||||
{
|
||||
|
||||
$h=0;
|
||||
@ -293,7 +279,7 @@ else
|
||||
$h++;
|
||||
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
@ -338,32 +324,35 @@ else
|
||||
|
||||
$uc = new User($db, $mil->user_creat);
|
||||
$uc->fetch();
|
||||
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>'.$uc->fullname.'</td>';
|
||||
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>'.$uc->getNomUrl(1).'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_creat).'</td></tr>';
|
||||
print '<td>'.dolibarr_print_date($mil->date_creat,"%d %b %Y %H:%M").'</td></tr>';
|
||||
|
||||
if ($mil->statut > 0)
|
||||
{
|
||||
$uv = new User($db, $mil->user_valid);
|
||||
$uv->fetch();
|
||||
print '<tr><td>'.$langs->trans("ValidatedBy").'</td><td>'.$uv->fullname.'</td>';
|
||||
print '<tr><td>'.$langs->trans("ValidatedBy").'</td><td>'.$uv->getNomUrl(1).'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_valid).'</td></tr>';
|
||||
print '<td>'.dolibarr_print_date($mil->date_valid,"%d %b %Y %H:%M").'</td></tr>';
|
||||
}
|
||||
|
||||
if ($mil->statut > 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("SentBy").'</td><td>'.$langs->trans("Unknown").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_envoi).'</td></tr>';
|
||||
print '<td>'.dolibarr_print_date($mil->date_envoi,"%d %b %Y %H:%M").'</td></tr>';
|
||||
}
|
||||
|
||||
// Contenu du mail
|
||||
// Sujet
|
||||
print '<tr><td>'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>';
|
||||
|
||||
// Message
|
||||
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print nl2br($mil->body).'</td></tr>';
|
||||
print nl2br($mil->body);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -415,13 +404,13 @@ else
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->fromname = $mil->email_from;
|
||||
$formmail->frommail = $mil->email_from;
|
||||
$formmail->withfrom=1;
|
||||
$formmail->withfrom=0;
|
||||
$formmail->withto=$user->email?$user->email:1;
|
||||
$formmail->withcc=0;
|
||||
$formmail->withtopic=$mil->sujet;
|
||||
$formmail->withtopic=0;
|
||||
$formmail->withtopicreadonly=1;
|
||||
$formmail->withfile=0;
|
||||
$formmail->withbody=$mil->body;
|
||||
$formmail->withbody=0;
|
||||
$formmail->withbodyreadonly=1;
|
||||
// Tableau des substitutions
|
||||
$formmail->substit["__FACREF__"]=$fac->ref;
|
||||
|
||||
@ -69,10 +69,10 @@ class Mailing
|
||||
$this->db = $DB ;
|
||||
$this->db_table = MAIN_DB_PREFIX."mailing";
|
||||
|
||||
$this->statuts[0] = $langs->trans("MailingStatusDraft");
|
||||
$this->statuts[1] = $langs->trans("MailingStatusValidated");
|
||||
$this->statuts[2] = $langs->trans("MailingStatusSentPartialy");
|
||||
$this->statuts[3] = $langs->trans("MailingStatusSentCompletely");
|
||||
$this->statuts[0] = $langs->trans("MailingStatusDraft");
|
||||
$this->statuts[1] = $langs->trans("MailingStatusValidated");
|
||||
$this->statuts[2] = $langs->trans("MailingStatusSentPartialy");
|
||||
$this->statuts[3] = $langs->trans("MailingStatusSentCompletely");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,62 +163,65 @@ class Mailing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recupére l'objet mailing
|
||||
* \param rowid id du mailing
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body";
|
||||
$sql .= " , m.email_from, m.email_replyto, m.email_errorsto";
|
||||
$sql .= " , m.statut, m.nbemail";
|
||||
$sql .= ", m.fk_user_creat, m.fk_user_valid, m.fk_user_appro";
|
||||
$sql .= ", ".$this->db->pdate("m.date_creat") . " as date_creat";
|
||||
$sql .= ", ".$this->db->pdate("m.date_valid") . " as date_valid";
|
||||
$sql .= ", ".$this->db->pdate("m.date_envoi") . " as date_envoi";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||
$sql .= " WHERE m.rowid = ".$rowid;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
/**
|
||||
* \brief Recupére l'objet mailing
|
||||
* \param rowid id du mailing
|
||||
* \return int
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->statut = $obj->statut;
|
||||
$this->nbemail = $obj->nbemail;
|
||||
$this->titre = stripslashes($obj->titre);
|
||||
$this->sujet = stripslashes($obj->sujet);
|
||||
$this->body = stripslashes($obj->body);
|
||||
|
||||
$this->email_from = $obj->email_from;
|
||||
$this->email_replyto = $obj->email_replyto;
|
||||
$this->email_errorsto = $obj->email_errorsto;
|
||||
|
||||
$this->user_creat = $obj->fk_user_creat;
|
||||
$this->user_valid = $obj->fk_user_valid;
|
||||
$this->user_appro = $obj->fk_user_appro;
|
||||
|
||||
$this->date_creat = $obj->date_creat;
|
||||
$this->date_valid = $obj->date_valid;
|
||||
$this->date_appro = $obj->date_appro;
|
||||
$this->date_envoi = $obj->date_envoi;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Fetch Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body";
|
||||
$sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
|
||||
$sql .= ", m.statut, m.nbemail";
|
||||
$sql .= ", m.fk_user_creat, m.fk_user_valid, m.fk_user_appro";
|
||||
$sql .= ", ".$this->db->pdate("m.date_creat") . " as date_creat";
|
||||
$sql .= ", ".$this->db->pdate("m.date_valid") . " as date_valid";
|
||||
$sql .= ", ".$this->db->pdate("m.date_envoi") . " as date_envoi";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||
$sql .= " WHERE m.rowid = ".$rowid;
|
||||
|
||||
dolibarr_syslog("Mailing.class::fetch sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->statut = $obj->statut;
|
||||
$this->nbemail = $obj->nbemail;
|
||||
$this->titre = $obj->titre;
|
||||
$this->sujet = $obj->sujet;
|
||||
$this->body = $obj->body;
|
||||
|
||||
$this->email_from = $obj->email_from;
|
||||
$this->email_replyto = $obj->email_replyto;
|
||||
$this->email_errorsto = $obj->email_errorsto;
|
||||
|
||||
$this->user_creat = $obj->fk_user_creat;
|
||||
$this->user_valid = $obj->fk_user_valid;
|
||||
$this->user_appro = $obj->fk_user_appro;
|
||||
|
||||
$this->date_creat = $obj->date_creat;
|
||||
$this->date_valid = $obj->date_valid;
|
||||
$this->date_appro = $obj->date_appro;
|
||||
$this->date_envoi = $obj->date_envoi;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Fetch Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Fetch Erreur -2");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Fetch Erreur -2");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -335,10 +338,10 @@ class Mailing
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($statut == 0) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut0');
|
||||
if ($statut == 1) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
|
||||
if ($statut == 2) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut3');
|
||||
if ($statut == 3) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
if ($statut == 0) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut0');
|
||||
if ($statut == 1) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
|
||||
if ($statut == 2) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut3');
|
||||
if ($statut == 3) return $this->statuts[$statut].' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ create table llx_mailing
|
||||
|
||||
statut smallint DEFAULT 0, --
|
||||
|
||||
date_envoi datetime, -- date d'envoi
|
||||
titre varchar(60), -- company name
|
||||
sujet varchar(60), -- company name
|
||||
body text,
|
||||
@ -44,8 +43,9 @@ create table llx_mailing
|
||||
email_errorsto varchar(160), -- company name
|
||||
|
||||
date_creat datetime, -- creation date
|
||||
date_valid datetime, -- creation date
|
||||
date_appro datetime, -- creation date
|
||||
date_valid datetime, --
|
||||
date_appro datetime, --
|
||||
date_envoi datetime, -- date d'envoi
|
||||
|
||||
fk_user_creat integer, -- utilisateur qui a créé l'info
|
||||
fk_user_valid integer, -- utilisateur qui a créé l'info
|
||||
|
||||
Loading…
Reference in New Issue
Block a user