diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index f5def186abb..b45e4d0d308 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -362,11 +362,11 @@ class FormOther $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")"; if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.fk_societe = ".($user->societe_id?$user->societe_id:0); - // Add existing sales representatives of company + // Add existing sales representatives of thirdparty of external user if (empty($user->rights->user->user->lire) && $user->societe_id) { $sql_usr.=" UNION "; - $sql_usr.= "SELECT u2.rowid, u2.name as name, u2.firstname, u2.login"; + $sql_usr.= "SELECT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")"; $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id;