Fix send remind by email
This commit is contained in:
parent
b96650b541
commit
471e1d71a0
@ -2750,6 +2750,9 @@ class Adherent extends CommonObject
|
|||||||
$nbok = 0;
|
$nbok = 0;
|
||||||
$nbko = 0;
|
$nbko = 0;
|
||||||
|
|
||||||
|
$listofmembersok = array();
|
||||||
|
$listofmembersko = array();
|
||||||
|
|
||||||
$arraydaysbeforeend=explode(';', $daysbeforeendlist);
|
$arraydaysbeforeend=explode(';', $daysbeforeendlist);
|
||||||
foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay
|
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');
|
$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 = '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);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -2787,6 +2791,7 @@ class Adherent extends CommonObject
|
|||||||
if (empty($adherent->email))
|
if (empty($adherent->email))
|
||||||
{
|
{
|
||||||
$nbko++;
|
$nbko++;
|
||||||
|
$listofmembersko[$adherent->id]=$adherent->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2828,12 +2833,16 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $cmail->error;
|
$this->error = $cmail->error;
|
||||||
$this->errors += $cmail->errors;
|
if (! is_null($cmail->errors)) {
|
||||||
|
$this->errors += $cmail->errors;
|
||||||
|
}
|
||||||
$nbko++;
|
$nbko++;
|
||||||
|
$listofmembersko[$adherent->id]=$adherent->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$nbok++;
|
$nbok++;
|
||||||
|
$listofmembersok[$adherent->id]=$adherent->id;
|
||||||
|
|
||||||
$message = $msg;
|
$message = $msg;
|
||||||
$sendto = $to;
|
$sendto = $to;
|
||||||
@ -2892,7 +2901,10 @@ class Adherent extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding";
|
$blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding";
|
||||||
|
|
||||||
$nbko++;
|
$nbko++;
|
||||||
|
$listofmembersko[$adherent->id]=$adherent->id;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2916,7 +2928,39 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->output = 'Found '.($nbok + $nbko).' members to send reminder to.';
|
$this->output = 'Found '.($nbok + $nbko).' members to send reminder to.';
|
||||||
$this->output.= ' Send email successfuly to '.$nbok.' members';
|
$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;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user