Can resend an emailing
This commit is contained in:
parent
0a8402fe64
commit
a00f87a28c
@ -129,6 +129,7 @@ if ($_POST["action"] == 'sendallconfirmed')
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
|
||||
|
||||
dolibarr_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -136,7 +137,7 @@ if ($_POST["action"] == 'sendallconfirmed')
|
||||
|
||||
if ($num)
|
||||
{
|
||||
dolibarr_syslog("mailing-send: nb of targets = ".$num, LOG_DEBUG);
|
||||
dolibarr_syslog("fiche.php: nb of targets = ".$num, LOG_DEBUG);
|
||||
|
||||
// Positionne date debut envoi
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$id;
|
||||
@ -157,15 +158,15 @@ if ($_POST["action"] == 'sendallconfirmed')
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// sendto en RFC2822
|
||||
$sendto = $obj->prenom." ".$obj->nom." <".$obj->email.">";
|
||||
$sendto = eregi_replace(',',' ',$obj->prenom." ".$obj->nom)." <".$obj->email.">";
|
||||
|
||||
// Pratique les substitutions sur le sujet et message
|
||||
// Make subtsitutions on topic and body
|
||||
$other=split(';',$obj->other);
|
||||
$other1=$other[0];
|
||||
$other2=$other[1];
|
||||
$other3=$other[3];
|
||||
$other4=$other[4];
|
||||
$other5=$other[5];
|
||||
$other3=$other[2];
|
||||
$other4=$other[3];
|
||||
$other5=$other[4];
|
||||
$substitutionarray=array(
|
||||
'__ID__' => $obj->rowid,
|
||||
'__EMAIL__' => $obj->email,
|
||||
@ -387,7 +388,8 @@ if ($_POST["action"] == 'confirm_valide')
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_approve')
|
||||
// Resend
|
||||
if ($_POST["action"] == 'confirm_reset')
|
||||
{
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
@ -395,10 +397,25 @@ if ($_POST["action"] == 'confirm_approve')
|
||||
|
||||
if ($mil->fetch($_GET["id"]) >= 0)
|
||||
{
|
||||
$mil->approve($user);
|
||||
$db->begin();
|
||||
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
exit;
|
||||
$result=$mil->valid($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$result=$mil->reset_targets_status($user);
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
Header("Location: fiche.php?id=".$mil->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg=$mil->error;
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -513,7 +530,14 @@ else
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// Confirmation de la suppression
|
||||
// Confirm reset
|
||||
if ($_GET["action"] == 'reset')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("ResetMailing"),$langs->trans("ConfirmResetMailing",$mil->ref),"confirm_reset");
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// Confirm delete
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete");
|
||||
@ -653,7 +677,12 @@ else
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&object=emailing&id='.$mil->id.'">'.$langs->trans("ToClone").'</a>';
|
||||
}
|
||||
|
||||
if ($mil->statut <= 1 && $user->rights->mailing->supprimer)
|
||||
if (($mil->statut == 2 || $mil->statut == 3) && $user->rights->mailing->valider)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=reset&id='.$mil->id.'">'.$langs->trans("ResetMailing").'</a>';
|
||||
}
|
||||
|
||||
if (($mil->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>';
|
||||
}
|
||||
@ -722,7 +751,11 @@ else
|
||||
print '__EMAIL__ = '.$langs->trans("EMail").'<br>';
|
||||
print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>';
|
||||
print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>';
|
||||
print '__OTHER1__ = '.$langs->trans("Other").'<br>';
|
||||
print '__OTHER1__ = '.$langs->trans("Other").'1<br>';
|
||||
print '__OTHER2__ = '.$langs->trans("Other").'2<br>';
|
||||
print '__OTHER3__ = '.$langs->trans("Other").'3<br>';
|
||||
print '__OTHER4__ = '.$langs->trans("Other").'4<br>';
|
||||
print '__OTHER5__ = '.$langs->trans("Other").'5<br>';
|
||||
print '</i></td>';
|
||||
print '<td colspan="3">';
|
||||
// Editeur wysiwyg
|
||||
|
||||
@ -35,10 +35,10 @@ class Mailing extends CommonObject
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
var $element='mailing';
|
||||
var $table_element='mailing';
|
||||
var $element='mailing';
|
||||
var $table_element='mailing';
|
||||
|
||||
var $id;
|
||||
var $id;
|
||||
var $statut;
|
||||
var $titre;
|
||||
var $sujet;
|
||||
@ -292,40 +292,78 @@ class Mailing extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Valide le mailing
|
||||
* \param user objet user qui valide
|
||||
* \brief Validate emailing
|
||||
* \param user Objet user qui valide
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function valid($user)
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND statut = 0 ;";
|
||||
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(gmmktime()).", fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
dol_syslog("Mailing::valid sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid Erreur -1");
|
||||
return -1;
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Mailing::Valid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Supprime le mailing
|
||||
* \brief Delete emailing
|
||||
* \param rowid id du mailing a supprimer
|
||||
* \return int 1 en cas de succes
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
|
||||
$this->db->query($sql);
|
||||
return 1;
|
||||
dol_syslog("Mailing::delete sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Mailing::Valid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Change status of each recipient
|
||||
* \param user Objet user qui valide
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function reset_targets_status($user)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql.= " SET statut = 0";
|
||||
$sql.= " WHERE fk_mailing = ".$this->id;
|
||||
|
||||
dol_syslog("Mailing::reset_targets_status sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog("Mailing::Valid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ ShowEMailing=Show emailing
|
||||
ListOfEMailings=List of emailings
|
||||
NewMailing=New emailing
|
||||
EditMailing=Edit emailing
|
||||
ResetMailing=Resend emailing
|
||||
DeleteMailing=Delete emailing
|
||||
DeleteAMailing=Delete an emailing
|
||||
PreviewMailing=Preview emailing
|
||||
@ -46,6 +47,7 @@ MailSuccessfulySent=Email successfuly sent (from %s to %s)
|
||||
ErrorMailRecipientIsEmpty=Email recipient is empty
|
||||
WarningNoEMailsAdded=No new Email to add to recipient's list.
|
||||
ConfirmValidMailing=Are you sure you want to validate this emailing ?
|
||||
ConfirmResetMailing=Warning, by reinitializing emailing <b>%s</b>, you allow to make a mass sending of this email another time. Are you sure you this is what you want to do ?
|
||||
ConfirmDeleteMailing=Are you sure you want to delete this emailling ?
|
||||
NbOfRecipients=Number of recipients
|
||||
NbOfUniqueEMails=Nb of unique emails
|
||||
|
||||
@ -24,6 +24,7 @@ ShowEMailing=Afficher emailing
|
||||
ListOfEMailings=Liste des emailings
|
||||
NewMailing=Nouvel emailing
|
||||
EditMailing=Éditer emailing
|
||||
ResetMailing=Nouvel envoi
|
||||
DeleteMailing=Supprimer emailing
|
||||
DeleteAMailing=Supprimer un emailing
|
||||
PreviewMailing=Prévisualiser emailing
|
||||
@ -46,6 +47,7 @@ MailSuccessfulySent=Mail correctement envoyé (de %s à %s)
|
||||
ErrorMailRecipientIsEmpty=L'adresse du destinataire est vide
|
||||
WarningNoEMailsAdded=Aucun nouvel e-mail à ajouter à la liste des destinataires.
|
||||
ConfirmValidMailing=Confirmez-vous la validation du mailing ?
|
||||
ConfirmResetMailing=Attention, en réinitialisation le mailing <b>%s</b>, vous autorisez son émission en masse une nouvelle fois. Est-ce bien ce que vous voulez faire ?
|
||||
ConfirmDeleteMailing=Confirmez-vous la suppression du mailing ?
|
||||
NbOfRecipients=Nombre de destinataires
|
||||
NbOfUniqueEMails=Nb d'e-mails uniques
|
||||
|
||||
Loading…
Reference in New Issue
Block a user