Skip to content

Commit

Permalink
Fix: use company name if lastname and firstname not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Sep 24, 2012
1 parent 665526a commit 930f492
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 3 additions & 1 deletion htdocs/adherents/index.php
Expand Up @@ -245,6 +245,7 @@
if (! empty($obj->fk_soc)) {
$staticmember->socid = $obj->fk_soc;
$staticmember->fetch_thirdparty();
$staticmember->name=$staticmember->thirdparty->name;
} else {
$staticmember->name=$obj->company;
}
Expand Down Expand Up @@ -305,7 +306,8 @@
$staticmember->firstname=$obj->firstname;
if (! empty($obj->fk_soc)) {
$staticmember->socid = $obj->fk_soc;
$staticmember->fetch_thirdparty();
$staticmember->fetch_thirdparty();
$staticmember->name=$staticmember->thirdparty->name;
} else {
$staticmember->name=$obj->company;
}
Expand Down
23 changes: 14 additions & 9 deletions htdocs/adherents/liste.php
Expand Up @@ -82,7 +82,7 @@

$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.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation";
Expand Down Expand Up @@ -267,6 +267,14 @@
$memberstatic->lastname=$objp->lastname;
$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;
print "<tr ".$bc[$var].">";

Expand All @@ -276,14 +284,11 @@
print "</td>\n";

// Lastname
if ($objp->societe != '')
{
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";
}
else
{
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".dol_trunc($memberstatic->getFullName($langs))."</a></td>\n";
}
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">";
print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : '');
print (! empty($companyname) ? dol_trunc($companyname, 32) : '');
print "</a></td>\n";

// Login
print "<td>".$objp->login."</td>\n";
Expand Down
11 changes: 10 additions & 1 deletion htdocs/core/boxes/box_members.php
Expand Up @@ -73,7 +73,8 @@ function loadBox($max=5)

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.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE a.entity = ".$conf->entity;
Expand All @@ -97,6 +98,14 @@ function loadBox($max=5)
$memberstatic->lastname=$objp->lastname;
$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"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/adherents/fiche.php?rowid=".$objp->rowid);
Expand Down

0 comments on commit 930f492

Please sign in to comment.