From caa3661eeb509479dcb7e29cafcab0e3b6a3f718 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 1 Jul 2020 09:16:44 +0200 Subject: [PATCH] NEW add order by lastname and firstname by default in get sales representatives --- htdocs/societe/class/societe.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a74c0de7c52..935b44ab16d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2070,11 +2070,13 @@ class Societe extends CommonObject /** * Return array of sales representatives * - * @param User $user Object user - * @param int $mode 0=Array with properties, 1=Array of id. - * @return array Array of sales representatives of third party + * @param User $user Object user + * @param int $mode 0=Array with properties, 1=Array of id. + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb' + * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; + * @return array Array of sales representatives of third party */ - public function getSalesRepresentatives(User $user, $mode = 0) + public function getSalesRepresentatives(User $user, $mode = 0, $sortfield = null, $sortorder = null) { global $conf; @@ -2091,6 +2093,11 @@ class Societe extends CommonObject } else $sql .= " WHERE entity in (0, ".$conf->entity.")"; $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; + if (empty($sortfield) && empty($sortorder)) { + $sortfield = 'u.lastname,u.firstname'; + $sortorder = 'ASC,ASC'; + } + $sql .= $this->db->order($sortfield, $sortorder); $resql = $this->db->query($sql); if ($resql)