From 0a11d52d5357383ff3589f7b8dccbe4241f5183f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jan 2018 12:46:07 +0100 Subject: [PATCH] Fix info on email sent --- htdocs/comm/mailing/card.php | 13 +++++++++++-- htdocs/comm/mailing/cibles.php | 13 +++++++++++-- htdocs/comm/mailing/class/mailing.class.php | 20 +++++++++++--------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b8aa549aa83..ba9ae256e94 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -875,7 +875,16 @@ else $linkback = ''.$langs->trans("BackToList").''; $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.=')   '; + } 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) { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 37724b62215..ed4a548cadb 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -185,7 +185,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; $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.=')   '; + } 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) { diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 72c2b6d4690..63fc0a2caab 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -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