New: Show name of sales representatives if number is lower than 3
This commit is contained in:
parent
c5b96bd327
commit
b21d3fad2a
@ -1225,6 +1225,41 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return array of sales representatives
|
||||||
|
* @return array Array of sales representatives of third party
|
||||||
|
*/
|
||||||
|
function getSalesRepresentatives($user='')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$reparray=array();
|
||||||
|
|
||||||
|
$sql = "SELECT u.rowid, u.name, u.firstname";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql.= " WHERE u.rowid = sc.fk_user AND sc.fk_soc =".$this->id;
|
||||||
|
$sql.= " AND entity in (0, ".$conf->entity.")";
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$i=0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$reparray[$i]['id']=$obj->rowid;
|
||||||
|
$reparray[$i]['name']=$obj->name;
|
||||||
|
$reparray[$i]['firstname']=$obj->firstname;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return $reparray;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dol_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the price level
|
* Set the price level
|
||||||
|
|||||||
@ -1664,26 +1664,29 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
|
|
||||||
$sql = "SELECT count(sc.rowid) as nb";
|
$listsalesrepresentatives=$soc->getSalesRepresentatives($user);
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
$nbofsalesrepresentative=sizeof($listsalesrepresentatives);
|
||||||
$sql.= " WHERE sc.fk_soc =".$soc->id;
|
if ($nbofsalesrepresentative > 3) // We print only number
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">';
|
||||||
$obj = $db->fetch_object($resql);
|
print $nbofsalesrepresentative;
|
||||||
if ($obj->nb)
|
print '</a>';
|
||||||
{
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">';
|
|
||||||
print $obj->nb;
|
|
||||||
print '</a>';
|
|
||||||
}
|
|
||||||
else print $langs->trans("NoSalesRepresentativeAffected");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
else if ($nbofsalesrepresentative > 0)
|
||||||
|
{
|
||||||
|
$userstatic=new User($db);
|
||||||
|
$i=1;
|
||||||
|
foreach($listsalesrepresentatives as $val)
|
||||||
|
{
|
||||||
|
$userstatic->id=$val['id'];
|
||||||
|
$userstatic->nom=$val['name'];
|
||||||
|
$userstatic->prenom=$val['firstname'];
|
||||||
|
print $userstatic->getNomUrl(1);
|
||||||
|
$i++;
|
||||||
|
if ($i < 3) print ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else print $langs->trans("NoSalesRepresentativeAffected");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Module Adherent
|
// Module Adherent
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user