New: Show name of sales representatives if number is lower than 3

This commit is contained in:
Regis Houssin 2011-02-09 11:08:06 +00:00
parent b6948d7606
commit 77d06b7a7c

View File

@ -261,21 +261,30 @@ class ActionsCardCommon
$this->tpl['display_rib'] = $this->object->display_rib(); $this->tpl['display_rib'] = $this->object->display_rib();
// Sales representatives // Sales representatives
// TODO move in business class $this->tpl['sales_representatives'] = '';
$sql = "SELECT count(sc.rowid) as nb"; $listsalesrepresentatives=$this->object->getSalesRepresentatives($user);
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $nbofsalesrepresentative=sizeof($listsalesrepresentatives);
$sql.= " WHERE sc.fk_soc =".$this->object->id; if ($nbofsalesrepresentative > 3) // We print only number
$resql = $this->db->query($sql);
if ($resql)
{ {
$num = $this->db->num_rows($resql); $this->tpl['sales_representatives'].= '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->id.'">';
$obj = $this->db->fetch_object($resql); $this->tpl['sales_representatives'].= $nbofsalesrepresentative;
$this->tpl['sales_representatives'] = $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected"); $this->tpl['sales_representatives'].= '</a>';
} }
else else if ($nbofsalesrepresentative > 0)
{ {
dol_print_error($this->db); $userstatic=new User($db);
$i=0;
foreach($listsalesrepresentatives as $val)
{
$userstatic->id=$val['id'];
$userstatic->nom=$val['name'];
$userstatic->prenom=$val['firstname'];
$this->tpl['sales_representatives'].= $userstatic->getNomUrl(1);
$i++;
if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'].= ', ';
}
} }
else $this->tpl['sales_representatives'].= $langs->trans("NoSalesRepresentativeAffected");
// Linked member // Linked member
if ($conf->adherent->enabled) if ($conf->adherent->enabled)