From 930f492a14a697823ff2cca376eef4890eb719ea Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 24 Sep 2012 12:05:12 +0200 Subject: [PATCH] Fix: use company name if lastname and firstname not exists --- htdocs/adherents/index.php | 4 +++- htdocs/adherents/liste.php | 23 ++++++++++++++--------- htdocs/core/boxes/box_members.php | 11 ++++++++++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 3777c94f788bb..e925539432cbf 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -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; } @@ -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; } diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index e2bf9a5dad740..85fe990c3d794 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -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"; @@ -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 ""; @@ -276,14 +284,11 @@ print "\n"; // Lastname - if ($objp->societe != '') - { - print "rowid\">".((! empty($obj->lastname) && ! empty($obj->firstname))?dol_trunc($memberstatic->getFullName($langs))." / ":'').dol_trunc($objp->societe,32)."\n"; - } - else - { - print "rowid\">".dol_trunc($memberstatic->getFullName($langs))."\n"; - } + print "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 "\n"; // Login print "".$objp->login."\n"; diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index d1fc2b2e78b9f..17125f02eb1b2 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -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; @@ -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);