Fix error management

This commit is contained in:
Laurent Destailleur 2022-11-23 18:52:43 +01:00
parent 459961711e
commit 4d11b5db31

View File

@ -2913,17 +2913,18 @@ class Adherent extends CommonObject
dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG);
if (!is_numeric($daysbeforeend)) {
$blockingerrormsg = "Value for delta is not a positive or negative numeric";
$blockingerrormsg = "Value for delta is not a numeric value";
$nbko++;
break;
}
$tmp = dol_getdate($now);
$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'], 'tzserver'), $daysbeforeend, 'd');
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent';
$sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only;
$sql .= " WHERE entity = ".((int) $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)."'";
//$sql .= " LIMIT 10000";
$resql = $this->db->query($sql);
if ($resql) {
@ -2956,7 +2957,7 @@ class Adherent extends CommonObject
dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang);
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
$labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION');
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
@ -2980,7 +2981,7 @@ class Adherent extends CommonObject
$result = $cmail->sendfile();
if (!$result) {
$error++;
$this->error = $cmail->error;
$this->error .= $cmail->error.' ';
if (!is_null($cmail->errors)) {
$this->errors += $cmail->errors;
}
@ -2998,8 +2999,7 @@ class Adherent extends CommonObject
$extraparams = '';
$actionmsg = '';
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.
CMailFile::getValidAddress($sendto, 4, 0, 1);
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
if ($message) {
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
@ -3046,7 +3046,10 @@ class Adherent extends CommonObject
$actioncomm->create($user);
}
} else {
$blockingerrormsg = "Can't find email template, defined into member module setup, to use for reminding";
//$blockingerrormsg = "Can't find email template with label=".$labeltouse.", to use for the reminding email";
$error++;
$this->error .= "Can't find email template with label=".$labeltouse.", to use for the reminding email ";
$nbko++;
$listofmembersko[$adherent->id] = $adherent->id;
@ -3088,7 +3091,7 @@ class Adherent extends CommonObject
if ($listofids) {
$listofids .= ']';
}
$this->output .= $listofids;
$this->output .= ' ids='.$listofids;
}
if ($nbko) {
$this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)';
@ -3116,6 +3119,6 @@ class Adherent extends CommonObject
}
}
return 0;
return $nbko;
}
}