From d0ab1db19b239ef8f9c9fc28beb73a7c3577ac88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Feb 2016 14:21:44 +0100 Subject: [PATCH] NEW When emailing is not sent completely, show progression --- htdocs/comm/mailing/cibles.php | 23 ++++++++++--- htdocs/comm/mailing/class/mailing.class.php | 34 ++++++++++++++++++- .../mysql/tables/llx_mailing_cibles.sql | 2 +- htdocs/langs/en_US/mails.lang | 1 + 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f817e7898d3..0c133fac6df 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -196,7 +196,9 @@ if ($object->fetch($id) >= 0) print ''; // Status - print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; + print ''.$langs->trans("Status").''.$object->getLibStatut(4); + if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')'; + print ''; // Nb of distinct emails print ''; @@ -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='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; } - 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 ''; @@ -548,7 +556,12 @@ if ($object->fetch($id) >= 0) } else { - print ''.$langs->trans("NoTargetYet").''; + if ($object->statut < 2) + { + print ''; + print $langs->trans("NoTargetYet"); + print ''; + } } print "
"; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 7ac91d1ab31..0ac16635beb 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -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, ... diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.sql index a2210ac0155..72fdeca2925 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.sql @@ -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), diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 94a74604901..a5f620c7a7a 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -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 ?