diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index db103aa0652..e9f43319767 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -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
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index ea71df66320..86e309d586f 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -877,11 +877,11 @@ else
print '
'.$langs->trans('VATIntra').' | ';
print '';
$s = '';
-
+
if (empty($conf->global->MAIN_DISABLEVATCHECK))
{
$s.=' ';
-
+
if ($conf->use_javascript_ajax)
{
print "\n";
@@ -899,7 +899,7 @@ else
$s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
}
}
-
+
print $s;
print ' | ';
@@ -1259,11 +1259,11 @@ else
print ''.$langs->trans('VATIntra').' | ';
print '';
$s ='';
-
+
if (empty($conf->global->MAIN_DISABLEVATCHECK))
{
$s.=' ';
-
+
if ($conf->use_javascript_ajax)
{
print "\n";
@@ -1281,9 +1281,9 @@ else
$s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
}
}
-
+
print $s;
-
+
print ' | ';
print '';
@@ -1526,11 +1526,11 @@ else
$s='';
$s.=$soc->tva_intra;
$s.='';
-
+
if (empty($conf->global->MAIN_DISABLEVATCHECK))
{
$s.=' ';
-
+
if ($conf->use_javascript_ajax)
{
print "\n";
@@ -1664,26 +1664,29 @@ else
print '';
print '';
- $sql = "SELECT count(sc.rowid) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE sc.fk_soc =".$soc->id;
-
- $resql = $db->query($sql);
- if ($resql)
+ $listsalesrepresentatives=$soc->getSalesRepresentatives($user);
+ $nbofsalesrepresentative=sizeof($listsalesrepresentatives);
+ if ($nbofsalesrepresentative > 3) // We print only number
{
- $num = $db->num_rows($resql);
- $obj = $db->fetch_object($resql);
- if ($obj->nb)
- {
- print '';
- print $obj->nb;
- print '';
- }
- else print $langs->trans("NoSalesRepresentativeAffected");
- }
- else {
- dol_print_error($db);
+ print '';
+ print $nbofsalesrepresentative;
+ print '';
}
+ 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 ' | ';
// Module Adherent