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 .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||||
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
|
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
|
||||||
|
|
||||||
|
dolibarr_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -136,7 +137,7 @@ if ($_POST["action"] == 'sendallconfirmed')
|
|||||||
|
|
||||||
if ($num)
|
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
|
// Positionne date debut envoi
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$id;
|
$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);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
// sendto en RFC2822
|
// 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);
|
$other=split(';',$obj->other);
|
||||||
$other1=$other[0];
|
$other1=$other[0];
|
||||||
$other2=$other[1];
|
$other2=$other[1];
|
||||||
$other3=$other[3];
|
$other3=$other[2];
|
||||||
$other4=$other[4];
|
$other4=$other[3];
|
||||||
$other5=$other[5];
|
$other5=$other[4];
|
||||||
$substitutionarray=array(
|
$substitutionarray=array(
|
||||||
'__ID__' => $obj->rowid,
|
'__ID__' => $obj->rowid,
|
||||||
'__EMAIL__' => $obj->email,
|
'__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')
|
if ($_POST["confirm"] == 'yes')
|
||||||
{
|
{
|
||||||
@ -395,10 +397,25 @@ if ($_POST["action"] == 'confirm_approve')
|
|||||||
|
|
||||||
if ($mil->fetch($_GET["id"]) >= 0)
|
if ($mil->fetch($_GET["id"]) >= 0)
|
||||||
{
|
{
|
||||||
$mil->approve($user);
|
$db->begin();
|
||||||
|
|
||||||
Header("Location: fiche.php?id=".$mil->id);
|
$result=$mil->valid($user);
|
||||||
exit;
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -513,7 +530,14 @@ else
|
|||||||
print '<br>';
|
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')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
$html->form_confirm("fiche.php?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_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>';
|
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>';
|
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 '__EMAIL__ = '.$langs->trans("EMail").'<br>';
|
||||||
print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>';
|
print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>';
|
||||||
print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<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 '</i></td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
// Editeur wysiwyg
|
// Editeur wysiwyg
|
||||||
|
|||||||
@ -35,10 +35,10 @@ class Mailing extends CommonObject
|
|||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
var $element='mailing';
|
var $element='mailing';
|
||||||
var $table_element='mailing';
|
var $table_element='mailing';
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $statut;
|
var $statut;
|
||||||
var $titre;
|
var $titre;
|
||||||
var $sujet;
|
var $sujet;
|
||||||
@ -292,40 +292,78 @@ class Mailing extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Valide le mailing
|
* \brief Validate emailing
|
||||||
* \param user objet user qui valide
|
* \param user Objet user qui valide
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function valid($user)
|
function valid($user)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Mailing::Valid");
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||||
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid=".$user->id;
|
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(gmmktime()).", fk_user_valid=".$user->id;
|
||||||
$sql .= " WHERE rowid = ".$this->id." AND statut = 0 ;";
|
$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
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Mailing::Valid Erreur -1");
|
$this->error=$this->db->lasterror();
|
||||||
return -1;
|
dolibarr_syslog("Mailing::Valid ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime le mailing
|
* \brief Delete emailing
|
||||||
* \param rowid id du mailing a supprimer
|
* \param rowid id du mailing a supprimer
|
||||||
* \return int 1 en cas de succes
|
* \return int 1 en cas de succes
|
||||||
*/
|
*/
|
||||||
function delete($rowid)
|
function delete($rowid)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
||||||
$sql .= " WHERE rowid = ".$rowid;
|
$sql.= " WHERE rowid = ".$rowid;
|
||||||
|
|
||||||
$this->db->query($sql);
|
dol_syslog("Mailing::delete sql=".$sql, LOG_DEBUG);
|
||||||
return 1;
|
$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
|
ListOfEMailings=List of emailings
|
||||||
NewMailing=New emailing
|
NewMailing=New emailing
|
||||||
EditMailing=Edit emailing
|
EditMailing=Edit emailing
|
||||||
|
ResetMailing=Resend emailing
|
||||||
DeleteMailing=Delete emailing
|
DeleteMailing=Delete emailing
|
||||||
DeleteAMailing=Delete an emailing
|
DeleteAMailing=Delete an emailing
|
||||||
PreviewMailing=Preview emailing
|
PreviewMailing=Preview emailing
|
||||||
@ -46,6 +47,7 @@ MailSuccessfulySent=Email successfuly sent (from %s to %s)
|
|||||||
ErrorMailRecipientIsEmpty=Email recipient is empty
|
ErrorMailRecipientIsEmpty=Email recipient is empty
|
||||||
WarningNoEMailsAdded=No new Email to add to recipient's list.
|
WarningNoEMailsAdded=No new Email to add to recipient's list.
|
||||||
ConfirmValidMailing=Are you sure you want to validate this emailing ?
|
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 ?
|
ConfirmDeleteMailing=Are you sure you want to delete this emailling ?
|
||||||
NbOfRecipients=Number of recipients
|
NbOfRecipients=Number of recipients
|
||||||
NbOfUniqueEMails=Nb of unique emails
|
NbOfUniqueEMails=Nb of unique emails
|
||||||
|
|||||||
@ -24,6 +24,7 @@ ShowEMailing=Afficher emailing
|
|||||||
ListOfEMailings=Liste des emailings
|
ListOfEMailings=Liste des emailings
|
||||||
NewMailing=Nouvel emailing
|
NewMailing=Nouvel emailing
|
||||||
EditMailing=Éditer emailing
|
EditMailing=Éditer emailing
|
||||||
|
ResetMailing=Nouvel envoi
|
||||||
DeleteMailing=Supprimer emailing
|
DeleteMailing=Supprimer emailing
|
||||||
DeleteAMailing=Supprimer un emailing
|
DeleteAMailing=Supprimer un emailing
|
||||||
PreviewMailing=Prévisualiser emailing
|
PreviewMailing=Prévisualiser emailing
|
||||||
@ -46,6 +47,7 @@ MailSuccessfulySent=Mail correctement envoyé (de %s à %s)
|
|||||||
ErrorMailRecipientIsEmpty=L'adresse du destinataire est vide
|
ErrorMailRecipientIsEmpty=L'adresse du destinataire est vide
|
||||||
WarningNoEMailsAdded=Aucun nouvel e-mail à ajouter à la liste des destinataires.
|
WarningNoEMailsAdded=Aucun nouvel e-mail à ajouter à la liste des destinataires.
|
||||||
ConfirmValidMailing=Confirmez-vous la validation du mailing ?
|
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 ?
|
ConfirmDeleteMailing=Confirmez-vous la suppression du mailing ?
|
||||||
NbOfRecipients=Nombre de destinataires
|
NbOfRecipients=Nombre de destinataires
|
||||||
NbOfUniqueEMails=Nb d'e-mails uniques
|
NbOfUniqueEMails=Nb d'e-mails uniques
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user