NEW When emailing is not sent completely, show progression

This commit is contained in:
Laurent Destailleur 2016-02-12 14:21:44 +01:00
parent 2796875ed1
commit d0ab1db19b
4 changed files with 53 additions and 7 deletions

View File

@ -196,7 +196,9 @@ if ($object->fetch($id) >= 0)
print '</td></tr>';
// Status
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4);
if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')';
print '</td></tr>';
// Nb of distinct emails
print '<tr><td width="25%">';
@ -369,8 +371,14 @@ if ($object->fetch($id) >= 0)
if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." ";
$sql .= $db->order($sortfield,$sortorder);
$totalnbofrecord=$object->nbemail; // nbemail is a denormalized field storing nb of targets
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
$sql .= $db->plimit($limit+1, $offset);
$resql=$db->query($sql);
@ -394,7 +402,7 @@ if ($object->fetch($id) >= 0)
$cleartext='<br></div><div>'.$langs->trans("ToClearAllRecipientsClickHere").': '.'<input type="submit" name="clearlist" class="button" value="'.$langs->trans("TargetsReset").'">';
}
print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$totalnbofrecord,'',0,'','',$limit);
print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$nbtotalofrecords,'',0,'','',$limit);
print '</form>';
@ -548,7 +556,12 @@ if ($object->fetch($id) >= 0)
}
else
{
print '<tr '.$bc[false].'><td colspan="8">'.$langs->trans("NoTargetYet").'</td></tr>';
if ($object->statut < 2)
{
print '<tr '.$bc[false].'><td colspan="8">';
print $langs->trans("NoTargetYet");
print '</td></tr>';
}
}
print "</table><br>";

View File

@ -80,7 +80,7 @@ class Mailing extends CommonObject
$this->statut_dest[-1] = 'MailingStatusError';
$this->statut_dest[1] = 'MailingStatusSent';
$this->statut_dest[2] = 'MailingStatusRead';
$this->statut_dest[3] = 'MailingStatusNotContact';
$this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
}
@ -477,6 +477,38 @@ class Mailing extends CommonObject
}
}
/**
* Count number of target with status
*
* @param string Mode ('alreadysent' = Sent success or error)
* @return int Nb of target with status
*/
function countNbOfTargets($mode)
{
$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
{
$this->error='BadValueForParameterMode';
return -2;
}
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj) return $obj->nb;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
return 0;
}
/**
* Retourne le libelle du statut d'un mailing (brouillon, validee, ...

View File

@ -29,7 +29,7 @@ create table llx_mailing_cibles
email varchar(160) NOT NULL,
other varchar(255) NULL,
tag varchar(128) NULL,
statut smallint NOT NULL DEFAULT 0,
statut smallint NOT NULL DEFAULT 0, -- -1 = error, 0 = not sent, ...
source_url varchar(160),
source_id integer,
source_type varchar(16),

View File

@ -47,6 +47,7 @@ MailingSuccessfullyValidated=EMailing successfully validated
MailUnsubcribe=Unsubscribe
Unsuscribe=Unsubscribe
MailingStatusNotContact=Don't contact anymore
MailingStatusReadAndUnsubscribe=Read and unsubscribe
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 ?