diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ff2e5082736..ec4042cdf88 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2750,6 +2750,9 @@ class Adherent extends CommonObject $nbok = 0; $nbko = 0; + $listofmembersok = array(); + $listofmembersko = array(); + $arraydaysbeforeend=explode(';', $daysbeforeendlist); foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { @@ -2766,7 +2769,8 @@ class Adherent extends CommonObject $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; - $sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'"; + $sql.= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql.= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; $resql = $this->db->query($sql); if ($resql) @@ -2787,6 +2791,7 @@ class Adherent extends CommonObject if (empty($adherent->email)) { $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; } else { @@ -2828,12 +2833,16 @@ class Adherent extends CommonObject { $error++; $this->error = $cmail->error; - $this->errors += $cmail->errors; + if (! is_null($cmail->errors)) { + $this->errors += $cmail->errors; + } $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; } else { $nbok++; + $listofmembersok[$adherent->id]=$adherent->id; $message = $msg; $sendto = $to; @@ -2892,7 +2901,10 @@ class Adherent extends CommonObject else { $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding"; + $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; + break; } } @@ -2916,7 +2928,39 @@ class Adherent extends CommonObject { $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; $this->output.= ' Send email successfuly to '.$nbok.' members'; - if ($nbko) $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + if (is_array($listofmembersok)) { + $listofids = ''; $i = 0; + foreach($listofmembersok as $idmember) { + if ($i > 100) { + $listofids .= ', ...'; + break; + } + if (empty($listofids)) $listofids .= ' ['; + else $listofids .= ', '; + $listofids .= $idmember; + $i++; + } + if ($listofids) $listofids .= ']'; + $this->output .= $listofids; + } + if ($nbko) { + $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + if (is_array($listofmembersko)) { + $listofids = ''; $i = 0; + foreach($listofmembersko as $idmember) { + if ($i > 100) { + $listofids .= ', ...'; + break; + } + if (empty($listofids)) $listofids .= ' ['; + else $listofids .= ', '; + $listofids .= $idmember; + $i++; + } + if ($listofids) $listofids .= ']'; + $this->output .= $listofids; + } + } } return 0;