diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 87f1b3f14d9..71fd6f3caa1 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -621,7 +621,9 @@ if ($rowid > 0) if ($object->datefin) { print dol_print_date($object->datefin,'day'); - if ($object->datefin < ($now - $conf->adherent->cotisation->warning_delay) && $object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + if ($object->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } } else { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 58bb8283029..d83664fd392 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1741,7 +1741,7 @@ class Adherent extends CommonObject $now=dol_now(); - $sql = "SELECT a.rowid, a.datefin"; + $sql = "SELECT a.rowid, a.datefin, a.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " WHERE a.statut = 1"; $sql.= " AND a.entity IN (".getEntity('adherent', 1).")"; @@ -1758,11 +1758,16 @@ class Adherent extends CommonObject $response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1'; $response->img=img_object($langs->trans("Members"),"user"); + $adherentstatic = new Adherent($this->db); + while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - if ($this->db->jdate($obj->datefin) < ($now - $conf->adherent->cotisation->warning_delay)) { + $adherentstatic->datefin = $this->db->jdate($obj->datefin); + $adherentstatic->statut = $obj->statut; + + if ($adherentstatic->hasDelay()) { $response->nbtodolate++; } } @@ -1974,4 +1979,18 @@ class Adherent extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + public function hasDelay() + { + global $conf; + + //Only valid members + if ($this->statut <= 0) { + return false; + } + + $now = dol_now(); + + return $this->datefin < ($now - $conf->adherent->cotisation->warning_delay); + } + } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1cf2a8e5e09..9799ea2ecef 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -271,6 +271,8 @@ if ($resql) $memberstatic->ref=$objp->rowid; $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; + $memberstatic->statut=$objp->statut; + $memberstatic->datefin= $datefin; if (! empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -325,7 +327,9 @@ if ($resql) { print ''; print dol_print_date($datefin,'day'); - if ($datefin < ($now - $conf->adherent->cotisation->warning_delay) && $objp->statut > 0) print " ".img_warning($langs->trans("SubscriptionLate")); + if ($memberstatic->hasDelay()) { + print " ".img_warning($langs->trans("SubscriptionLate")); + } print ''; } else diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 928424b1d8b..4d2382e6eee 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -246,6 +246,8 @@ if ($id > 0 || ! empty($ref)) $memberstatic->ref=$objp->rowid; $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; + $memberstatic->statut=$objp->statut; + $memberstatic->datefin=$db->jdate($objp->datefin); $companyname=$objp->company; @@ -290,7 +292,9 @@ if ($id > 0 || ! empty($ref)) { print ''; print dol_print_date($datefin,'day'); - if ($datefin < ($now - $conf->adherent->cotisation->warning_delay) && $objp->statut > 0) print " ".img_warning($langs->trans("SubscriptionLate")); + if ($memberstatic->hasDelay()) { + print " ".img_warning($langs->trans("SubscriptionLate")); + } print ''; } else