Fix: use company name if lastname and firstname not exists

This commit is contained in:
Regis Houssin 2012-09-24 12:05:12 +02:00
parent 665526a6e7
commit 930f492a14
3 changed files with 27 additions and 11 deletions

View File

@ -245,6 +245,7 @@ if ($resql)
if (! empty($obj->fk_soc)) { if (! empty($obj->fk_soc)) {
$staticmember->socid = $obj->fk_soc; $staticmember->socid = $obj->fk_soc;
$staticmember->fetch_thirdparty(); $staticmember->fetch_thirdparty();
$staticmember->name=$staticmember->thirdparty->name;
} else { } else {
$staticmember->name=$obj->company; $staticmember->name=$obj->company;
} }
@ -305,7 +306,8 @@ if ($resql)
$staticmember->firstname=$obj->firstname; $staticmember->firstname=$obj->firstname;
if (! empty($obj->fk_soc)) { if (! empty($obj->fk_soc)) {
$staticmember->socid = $obj->fk_soc; $staticmember->socid = $obj->fk_soc;
$staticmember->fetch_thirdparty(); $staticmember->fetch_thirdparty();
$staticmember->name=$staticmember->thirdparty->name;
} else { } else {
$staticmember->name=$obj->company; $staticmember->name=$obj->company;
} }

View File

@ -82,7 +82,7 @@ llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute
$now=dol_now(); $now=dol_now();
$sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.societe, "; $sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.societe as company, d.fk_soc,";
$sql.= " d.datefin,"; $sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation"; $sql.= " t.libelle as type, t.cotisation";
@ -267,6 +267,14 @@ if ($resql)
$memberstatic->lastname=$objp->lastname; $memberstatic->lastname=$objp->lastname;
$memberstatic->firstname=$objp->firstname; $memberstatic->firstname=$objp->firstname;
if (! empty($objp->fk_soc)) {
$memberstatic->socid = $objp->fk_soc;
$memberstatic->fetch_thirdparty();
$companyname=$memberstatic->thirdparty->name;
} else {
$companyname=$objp->company;
}
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
@ -276,14 +284,11 @@ if ($resql)
print "</td>\n"; print "</td>\n";
// Lastname // Lastname
if ($objp->societe != '') print "<td><a href=\"fiche.php?rowid=$objp->rowid\">";
{ print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".((! empty($obj->lastname) && ! empty($obj->firstname))?dol_trunc($memberstatic->getFullName($langs))." / ":'').dol_trunc($objp->societe,32)."</a></td>\n"; print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : '');
} print (! empty($companyname) ? dol_trunc($companyname, 32) : '');
else print "</a></td>\n";
{
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".dol_trunc($memberstatic->getFullName($langs))."</a></td>\n";
}
// Login // Login
print "<td>".$objp->login."</td>\n"; print "<td>".$objp->login."</td>\n";

View File

@ -73,7 +73,8 @@ class box_members extends ModeleBoxes
if ($user->rights->societe->lire) if ($user->rights->societe->lire)
{ {
$sql = "SELECT a.rowid, a.nom as lastname, a.prenom as firstname, a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql = "SELECT a.rowid, a.nom as lastname, a.prenom as firstname, a.societe, a.fk_soc,";
$sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,";
$sql.= " t.cotisation"; $sql.= " t.cotisation";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE a.entity = ".$conf->entity; $sql.= " WHERE a.entity = ".$conf->entity;
@ -97,6 +98,14 @@ class box_members extends ModeleBoxes
$memberstatic->lastname=$objp->lastname; $memberstatic->lastname=$objp->lastname;
$memberstatic->firstname=$objp->firstname; $memberstatic->firstname=$objp->firstname;
if (! empty($objp->fk_soc)) {
$memberstatic->socid = $objp->fk_soc;
$memberstatic->fetch_thirdparty();
$memberstatic->name=$memberstatic->thirdparty->name;
} else {
$memberstatic->name=$objp->company;
}
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg, 'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/adherents/fiche.php?rowid=".$objp->rowid); 'url' => DOL_URL_ROOT."/adherents/fiche.php?rowid=".$objp->rowid);