Fix info on email sent

This commit is contained in:
Laurent Destailleur 2018-01-29 12:46:07 +01:00
parent 424e8a3139
commit 0a11d52d53
3 changed files with 33 additions and 13 deletions

View File

@ -875,7 +875,16 @@ else
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlright='';
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3)
{
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
$morehtmlright.=') &nbsp; ';
}
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@ -907,7 +916,7 @@ else
if (is_numeric($nbemail))
{
$text='';
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{

View File

@ -185,7 +185,16 @@ if ($object->fetch($id) >= 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlright='';
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3)
{
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
$morehtmlright.=') &nbsp; ';
}
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@ -210,7 +219,7 @@ if ($object->fetch($id) >= 0)
if (is_numeric($nbemail))
{
$text='';
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{

View File

@ -34,7 +34,7 @@ class Mailing extends CommonObject
public $element='mailing';
public $table_element='mailing';
public $picto='email';
var $titre;
var $sujet;
var $body;
@ -43,7 +43,7 @@ class Mailing extends CommonObject
var $bgimage;
var $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
var $email_from;
var $email_replyto;
var $email_errorsto;
@ -431,7 +431,7 @@ class Mailing extends CommonObject
return -1;
}
}
/**
* Delete targets emailing
*
@ -481,11 +481,11 @@ class Mailing extends CommonObject
}
}
/**
* Count number of target with status
*
* @param string $mode Mode ('alreadysent' = Sent success or error)
* @param string $mode Mode ('alreadysent' = Sent success or error, 'alreadysentok' = Sent success, 'alreadysentko' = Sent error)
* @return int Nb of target with status
*/
function countNbOfTargets($mode)
@ -493,12 +493,14 @@ class Mailing extends CommonObject
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql.= " WHERE fk_mailing = ".$this->id;
if ($mode == 'alreadysent') $sql.= " AND statut <> 0";
else
elseif ($mode == 'alreadysentok') $sql.= " AND statut > 0";
elseif ($mode == 'alreadysentko') $sql.= " AND statut = -1";
else
{
$this->error='BadValueForParameterMode';
return -2;
}
$resql=$this->db->query($sql);
if ($resql)
{
@ -512,10 +514,10 @@ class Mailing extends CommonObject
}
return 0;
}
/**
* Retourne le libelle du statut d'un mailing (brouillon, validee, ...
* Return label of status of emailing (draft, validated, ...)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Label