Created Adherent::hasDelay function

This commit is contained in:
Marcos García de La Fuente 2015-09-05 11:03:37 +02:00
parent 3c5159f497
commit 865489db75
4 changed files with 34 additions and 5 deletions

View File

@ -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
{

View File

@ -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&amp;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);
}
}

View File

@ -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 '<td align="center" class="nowrap">';
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 '</td>';
}
else

View File

@ -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 '<td align="center" class="nowrap">';
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 '</td>';
}
else