diff --git a/apps/maarch_entreprise/indexing_searching/search_adv_result.php b/apps/maarch_entreprise/indexing_searching/search_adv_result.php
index be76c70b43ad8cb155813c907339516528f948a7..94ea99a10c6f8770a1b1808956a00ccb8c84e003 100755
--- a/apps/maarch_entreprise/indexing_searching/search_adv_result.php
+++ b/apps/maarch_entreprise/indexing_searching/search_adv_result.php
@@ -185,9 +185,11 @@ if (count($_REQUEST['meta']) > 0) {
             // SIGNATORY GROUP
             elseif ($tab_id_fields[$j] == 'signatory_group' && !empty($_REQUEST['signatory_group'])) {
                 $json_txt .= " 'signatory_group' : ['".addslashes(trim($_REQUEST['signatory_group']))."'],";
-                $where_request .= " (res_id in (select res_id from listinstance where item_id in (select user_id from usergroup_content where group_id = :signatoryGroup) "
+
+                $where_request .= " (res_id in (select res_id from listinstance where item_id in (select user_id from users where id in (select user_id from usergroup_content where group_id = :signatoryGroup)) "
                         ."and item_mode = 'sign' and difflist_type = 'VISA_CIRCUIT')) ";
-                $arrayPDO = array_merge($arrayPDO, array(":signatoryGroup" => $_REQUEST['signatory_group']));
+                $group = \Group\models\GroupModel::getByGroupId(['groupId' => $_REQUEST['signatory_group'], 'select' => ['id']]);
+                $arrayPDO = array_merge($arrayPDO, array(":signatoryGroup" => $group['id']));
                 $where_request .=" and  ";
             }
 
diff --git a/core/class/ServiceControler.php b/core/class/ServiceControler.php
index 5dbd662d7aa5eb5b474bb1b1f5058a7518eab1d3..78b35ef74272a1d695a3a01ef85f96bca4d981a8 100755
--- a/core/class/ServiceControler.php
+++ b/core/class/ServiceControler.php
@@ -108,8 +108,8 @@ class ServiceControler
 	{
 		$services = array();
 		
-		// #TODO : Au lieu de partir des services, partir plutot des groupes de l'utilisateur et récuperer tous les services 
-		// associés aux groupes
+		// #TODO : Au lieu de partir des services, partir plutot des groupes de l'utilisateur et r�cuperer tous les services 
+		// associés aux groupes
 		if($user_id == "superadmin")
 		{
 			$services = self::getAllServices();
@@ -126,11 +126,11 @@ class ServiceControler
 			}
 			$ugc = new usergroups_controler();
 			self::connect();
+			$userUse = \User\models\UserModel::getByLogin(['login' => $user_id, 'select' => ['id']]);
 			$stmt = self::$db->query(
 				'select distinct us.service_id from ' . USERGROUPS_SERVICES_TABLE
-				. ' us, ' . USERGROUP_CONTENT_TABLE 
-				. " uc where us.group_id = uc.group_id and uc.user_id = ?", 
-				array($user_id)
+				. ' us, usergroup_content uc, usergroups where us.group_id = usergroups.group_id and usergroups.id = uc.group_id and uc.user_id = ?',
+				array($userUse['id'])
 			);
 			
 			while($res = $stmt->fetchObject()) {
diff --git a/core/class/class_core_tools.php b/core/class/class_core_tools.php
index 4a23b5caebbe7c51643f4f5eb6c2bbe8968d8a55..5881c9536ce352e32d1950eb75f67b9a7f08ad83 100755
--- a/core/class/class_core_tools.php
+++ b/core/class/class_core_tools.php
@@ -77,7 +77,6 @@ class core_tools extends functions
         $_SESSION['tablename']['security'] = (string) $TABLENAME->security;
         $_SESSION['tablename']['status'] = (string) $TABLENAME->status;
         $_SESSION['tablename']['usergroups'] = (string) $TABLENAME->usergroups;
-        $_SESSION['tablename']['usergroup_content'] = (string) $TABLENAME->usergroupcontent;
         $_SESSION['tablename']['usergroup_services'] = (string) $TABLENAME->usergroups_services;
         $_SESSION['tablename']['users'] = (string) $TABLENAME->users;
     }
diff --git a/core/class/class_history.php b/core/class/class_history.php
index 3404405111090f3994aa74d0de6e460cbdd991ab..84d722595f16cd35650f5cd8bef504521339a23d 100755
--- a/core/class/class_history.php
+++ b/core/class/class_history.php
@@ -413,10 +413,6 @@ class history
             $_SESSION['user']['department'] = '';
         }
 
-        if (!isset($_SESSION['user']['primarygroup'])) {
-            $_SESSION['user']['primarygroup'] = '';
-        }
-
         if (file_exists(
             'custom'
             . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
diff --git a/core/class/class_security.php b/core/class/class_security.php
index edfbd340029bcda1eaed8886f7eb3dcf68c66f3b..2fdcbbf8f8c1b06f4aa5602b85e6d2d3f660d979 100755
--- a/core/class/class_security.php
+++ b/core/class/class_security.php
@@ -171,9 +171,6 @@ class security extends Database
                     'cookie_date' => $user->__get('cookie_date')
                 );
 
-                $array['primarygroup'] = $ugc->getPrimaryGroup(
-                    $array['UserId']
-                );
                 $tmp = $sec_controler->load_security(
                     $array['UserId']
                 );
@@ -219,7 +216,6 @@ class security extends Database
                     }
                     $_SESSION['user']['UserId'] = $s_login;
                     $_SESSION['user']['department'] = $array['department'];
-                    $_SESSION['user']['primarygroup'] = $array['primarygroup'];
                     $hist->add(
                         $_SESSION['tablename']['users'],
                         $s_login,
diff --git a/core/class/usergroups_controler.php b/core/class/usergroups_controler.php
index 49f943d6255bc7ae1e1eba66bf3f451b46e59858..9631650aca37086162e6cad7b1ecb8a6444b2666 100755
--- a/core/class/usergroups_controler.php
+++ b/core/class/usergroups_controler.php
@@ -120,48 +120,20 @@ class usergroups_controler extends ObjectControler implements ObjectControlerIF
         if (empty($groupId)) {
             return null;
         }
-        $users = array();
-        $db = new Database();
-        $query = 'select user_id from ' . USERGROUP_CONTENT_TABLE
-               . " where group_id = ?";
-        try {
-            $stmt = $db->query($query, array($groupId));
-        } catch (Exception $e) {
-            echo _NO_GROUP_WITH_ID . ' ' . functions::xssafe($groupId) . ' // ';
-        }
-        while ($res = $stmt->fetchObject()) {
-            array_push($users, $res->user_id);
-        }
-        return $users;
-    }
 
-    /**
-    * Returns the id of the primary group for a given user_id
-    *
-    * @param  $userId string  User identifier
-    * @return String  group_id or null
-    */
-    public function getPrimaryGroup($userId)
-    {
-        if (empty($userId)) {
-            return null;
-        }
-        $users = array();
-        $db = new Database();
-        $query = 'select group_id from ' . USERGROUP_CONTENT_TABLE
-               . " where user_id = ?";
-        try {
-            $stmt = $db->query($query, array($userId));
-        } catch (Exception $e){
-            echo _NO_USER_WITH_ID.' '.functions::xssafe($userId).' // ';
-        }
-        $res = $stmt->fetchObject();
-        if (isset($res->group_id)) {
-            $groupId = $res->group_id;
+        $groupUse = \Group\models\GroupModel::getByGroupId(['groupId' => $groupId, 'select' => ['id']]);
+        $userGroup = \User\models\UserGroupModel::get(['select' => ['user_id'], 'where' => ['group_id = ?'], 'data' => [$groupUse['id']]]);
+        $userGroup = array_column($userGroup, 'user_id');
+
+        $userUse = [];
+        if (empty($userGroup)) {
+            echo _NO_GROUP_WITH_ID . ' ' . functions::xssafe($groupId) . ' // ';
         } else {
-            return null;
+            $userUse = \User\models\UserModel::get(['select' => ['user_id'], 'where' => ['id in (?)'], 'data' => [$userGroup]]);
+            $userUse = array_column($userUse, 'user_id');
         }
-        return $groupId;
+
+        return $userUse;
     }
 
     /**
@@ -474,118 +446,15 @@ class usergroups_controler extends ObjectControler implements ObjectControlerIF
         return $this->advanced_update($group);
     }
 
-    /**
-    * Deletes in the database (usergroups related tables) a given usergroup
-    *
-    * @param  $group usergroup object
-    * @return bool true if the deletion is complete, false otherwise
-    */
-    public function delete($group, $params = array())
-    {
-        $control = array();
-        if (!isset($group) || empty($group)) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _GROUP_EMPTY,
-            );
-            return $control;
-        }
-        $group = $this->_isAGroup($group);
-        if (!$this->groupExists($group->group_id)) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _GROUP_NOT_EXISTS,
-            );
-            return $control;
-        }
-
-        $this->set_foolish_ids(array('group_id'));
-        $this->set_specific_id('group_id');
-
-        $groupId = $group->__get('group_id');
-        $ok = $this->advanced_delete($group);
-        if ($ok) {
-            $ok = $this->_cleanUsergroupContent($groupId);
-        } else {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _IMPOSSIBLE_TO_DELETE_USER,
-            );
-        }
-
-        if ($ok) {
-            $ok = $this->deleteServicesForGroup($groupId);
-        } elseif (!isset($control['status']) || $control['status'] <> 'ko' ) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _PB_WITH_USERGROUP_CONTENT_CLEANING,
-            );
-        }
-
-        if ($ok) {
-            $secCtrl = new SecurityControler();
-            $ok = $secCtrl->deleteForGroup($groupId);
-        } elseif (!isset($control['status']) || $control['status'] <> 'ko' ) {
-            $control = array(
-                'status' => 'ko',
-                'value' => '',
-                'error' => _PB_WITH_USERGROUP_CONTENT_CLEANING,
-            );
-        }
-
-        if (!$ok
-            && (!isset($control['status']) || $control['status'] <> 'ko' )
-        ) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _PB_WITH_SECURITY_CLEANING,
-            );
-        }
-
-        if (isset($control['status']) && $control['status'] == 'ok') {
-            if (isset($params['log_group_del'])
-                && ($params['log_group_del'] == 'true'
-                    || $params['log_group_del'] == true)
-            ) {
-                $history = new history();
-                $history->add(
-                    USERGROUPS_TABLE, $group->group_id, 'DEL','usergroupdel',
-                    _DELETED_GROUP . ' : ' . $group->group_id,
-                    $params['databasetype']
-                );
-            }
-        }
-        return $control;
-    }
 
     /**
-    * Cleans the usergroup_content table in the database from a given usergroup
-    *  (group_id)
-    *
-    * @param  $groupId string  Usergroup identifier
-    * @return bool true if the cleaning is complete, false otherwise
-    */
-    private function _cleanUsergroupContent($groupId)
+     * Deletes in the database (usergroups related tables) a given usergroup
+     *
+     * @param  $group usergroup object
+     * @return bool true if the deletion is complete, false otherwise
+     */
+    public function delete($group, $params = array())
     {
-        if (!isset($groupId)|| empty($groupId)) {
-            return false;
-        }
-        $db = new Database();
-        $query = 'delete from ' . USERGROUP_CONTENT_TABLE . " where group_id=?";
-        try {
-            $stmt = $db->query($query, array($groupId));
-            $ok = true;
-        } catch (Exception $e){
-            echo _CANNOT_DELETE_GROUP_ID . ' ' . functions::xssafe($groupId) . ' // ';
-            $ok = false;
-        }
-
-        return $ok;
     }
 
 
@@ -778,46 +647,11 @@ class usergroups_controler extends ObjectControler implements ObjectControlerIF
         ) {
             return false;
         }
-        $db = new Database();
-        $query = 'select user_id from ' . USERGROUP_CONTENT_TABLE
-               . " where user_id = ? and group_id = ?";
+        $userUse = \User\models\UserModel::getByLogin(['login' => $userId, 'select' => ['id']]);
+        $groupUse = \Group\models\GroupModel::getByGroupId(['groupId' => $groupId, 'select' => ['id']]);
+        $userGroup = \User\models\UserGroupModel::get(['select' => [1], 'where' => ['user_id = ?', 'group_id = ?'], 'data' => [$userUse['id'], $groupUse['id']]]);
 
-        try {
-            $stmt = $db->query($query, array($userId, $groupId));
-        } catch (Exception $e) {
-            echo _CANNOT_FIND . ' ' . functions::xssafe($groupId) 
-                . ' ' . functions::xssafe($userId) . ' // ';
-        }
-        if ($stmt->rowCount() > 0) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-    * Returns the number of usergroup of the usergroups table
-    *   (only the enabled by default)
-    *
-    * @param  $enabledOnly Bool if true counts only the enabled ones,
-    *   otherwise counts all usergroups even the disabled ones (true by default)
-    * @return Integer the number of usergroups in the usergroups table
-    */
-    public function getUsergroupsCount($enabledOnly=true)
-    {
-        $nb = 0;
-        $db = new Database();
-        $query = 'select group_id from ' . USERGROUPS_TABLE . ' ' ;
-        if ($enabledOnly) {
-            $query .= "where enabled ='Y'";
-        }
-        try {
-            $stmt = $db->query($query);
-        } catch (Exception $e) {
-
-        }
-        $nb = $stmt->rowCount();
-        return $nb;
+        return !empty($userGroup);
     }
 
      /**
diff --git a/core/class/users_controler.php b/core/class/users_controler.php
index 38976a1827974453a639dc07f78dca341784fbab..f1079315d0adcba9c18702258e9f78042fc63c66 100755
--- a/core/class/users_controler.php
+++ b/core/class/users_controler.php
@@ -187,12 +187,11 @@ class users_controler extends ObjectControler implements ObjectControlerIF
             return null;
         }
         self::$db = new Database();
-        $func = new functions();
-        $query = 'select uc.group_id, uc.role from '
-               . USERGROUP_CONTENT_TABLE . ' uc, ' . USERGROUPS_TABLE
-               . " u where uc.user_id = ? and uc.group_id = u.group_id ";
+        $userUse = \User\models\UserModel::getByLogin(['login' => $userId, 'select' => ['id']]);
+
+        $query = 'select u.group_id, uc.role from usergroup_content uc, usergroups u where uc.user_id = ? and uc.group_id = u.id ';
         try {
-            $stmt = self::$db->query($query, array($userId));
+            $stmt = self::$db->query($query, array($userUse['id']));
         } catch (Exception $e){
             echo _NO_USER_WITH_ID.' '.functions::xssafe($userId).' // ';
         }
@@ -269,11 +268,6 @@ class users_controler extends ObjectControler implements ObjectControlerIF
         $control = self::_control($user, $groups, $mode, $params);
 
         if ($control['status'] == 'ok') {
-            if (! isset($params['manageGroups']) 
-                || $params['manageGroups'] == true
-            ) {
-                self::cleanUsergroupContent($user->user_id);
-            }
             $core = new core_tools();
 
             $_SESSION['service_tag'] = 'user_' . $mode;
@@ -481,158 +475,10 @@ class users_controler extends ObjectControler implements ObjectControlerIF
         return self::advanced_update($user);
     }
 
-    /**
-    * Deletes in the database (users related tables) a given user (user_id)
-    *
-    * @param  $user User Object
-    * @return bool true if the deletion is complete, false otherwise
-    */
-    public function delete($user, $params=array())
+    public function delete($user, $params = array())
     {
-        $core_tools = new core_tools();
-        
-        $control = array();
-        if (! isset($user) || empty($user)) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _USER_EMPTY,
-            );
-            return $control;
-        }
-        $user = self::_isAUser($user);
-        if (! self::userExists($user->user_id)) {
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _USER_NOT_EXISTS,
-            );
-            return $control;
-        }
-
-        self::$db = new Database();
-        
-        $func = new functions();
-        $query = 'update ' . USERS_TABLE . " set status = 'DEL' where user_id=?";
-
-        try{
-            $stmt = self::$db->query($query, array($user->user_id));
-            $ok = true;
-        } catch (Exception $e){
-            $control = array(
-                'status' => 'ko',
-                'value' => '',
-                'error' => _CANNOT_DELETE_USER_ID . ' ' . $user->user_id,
-            );
-            $ok = false;
-        }
-        
-        if ($ok) {
-            $control = self::cleanUsergroupContent($user->user_id);
-            $control = self::cleanUserentityContent($user->user_id);
-
-            if ($core_tools->is_module_loaded('entities')){
-                $listModels = new users_entities();
-                $listModels->cleanListModelsContent($user->user_id);
-            }
-        }
-
-        if ($control['status'] == 'ok') {
-            if (isset($params['log_user_del'])
-                && ($params['log_user_del'] == "true"
-                    || $params['log_user_del'] == true)
-            ) {
-                $history = new history();
-                $history->add(
-                    USERS_TABLE, $user->user_id, 'DEL', 'usersdel',
-                    _DELETED_USER . ' : ' . $user->lastname . ' '
-                    . $user->firstname . ' (' . $user->user_id . ')',
-                    $params['databasetype']
-                );
-            }
-        }
-        return $control;
     }
 
-    /**
-    * Cleans the usergroup_content table in the database from a given user
-    *   (user_id)
-    *
-    * @param  $userId string  User identifier
-    * @return bool true if the cleaning is complete, false otherwise
-    */
-    public function cleanUsergroupContent($userId)
-    {
-        $control = array();
-        if (! isset($userId) || empty($userId)) {
-            $control = array(
-                'status' => 'ko',
-                'value' => '',
-                'error' => _USER_ID_EMPTY,
-            );
-            return $control;
-        }
-
-        self::$db = new Database();
-        
-        $func = new functions();
-        $query = 'delete from ' . USERGROUP_CONTENT_TABLE . " where user_id=?";
-        try{
-            $stmt = self::$db->query($query, array($userId));
-            $control = array(
-                'status' => 'ok',
-                'value'  => $userId,
-            );
-        } catch (Exception $e){
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _CANNOT_CLEAN_USERGROUP_CONTENT . ' ' . $userId,
-            );
-        }
-        
-        return $control;
-    }
-
-    /**
-    * Cleans the users_entities table in the database from a given user
-    *   (user_id)
-    *
-    * @param  $userId string  User identifier
-    * @return bool true if the cleaning is complete, false otherwise
-    */
-    public function cleanUserentityContent($userId)
-    {
-        $control = array();
-        if (! isset($userId) || empty($userId)) {
-            $control = array(
-                'status' => 'ko',
-                'value' => '',
-                'error' => _USER_ID_EMPTY,
-            );
-            return $control;
-        }
-
-        self::$db = new Database();
-        
-        $func = new functions();
-        $query = "delete from users_entities where user_id=?";
-        try{
-            $stmt = self::$db->query($query, array($userId));
-            $control = array(
-                'status' => 'ok',
-                'value'  => $userId,
-            );
-        } catch (Exception $e){
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _CANNOT_CLEAN_USERENTITY_CONTENT . ' ' . $userId,
-            );
-        }
-        
-        return $control;
-    }
     /**
     * Asserts if a given user (user_id) exists in the database
     *
diff --git a/core/core_tables.php b/core/core_tables.php
index 5652f92176f3300153fabe1952e7b9cc7995eb16..ad82aae79b7eb169ef47dd320ffdcad4b3e599df 100755
--- a/core/core_tables.php
+++ b/core/core_tables.php
@@ -77,9 +77,6 @@ if (! defined('STATUS_TABLE')) {
 if (! defined('USERGROUPS_TABLE')) {
     define('USERGROUPS_TABLE', 'usergroups');
 }
-if (! defined('USERGROUP_CONTENT_TABLE')) {
-    define('USERGROUP_CONTENT_TABLE', 'usergroup_content');
-}
 if (! defined('USERGROUPS_SERVICES_TABLE')) {
     define('USERGROUPS_SERVICES_TABLE', 'usergroups_services');
 }
@@ -94,4 +91,4 @@ if (! defined('EMAIL_SIGNATURES_TABLE')) {
 }
 if (! defined('USER_SIGNATURES_TABLE')) {
     define('USER_SIGNATURES_TABLE', 'user_signatures');
-}
\ No newline at end of file
+}
diff --git a/core/xml/config.xml b/core/xml/config.xml
index da2201fe09b956757a535f80b6faea2c420fc3b7..bebf93b1231cb70b2f87d196e44ca238baab25fd 100755
--- a/core/xml/config.xml
+++ b/core/xml/config.xml
@@ -19,7 +19,6 @@
         <security>security</security>
         <status>status</status>
         <usergroups>usergroups</usergroups>
-        <usergroupcontent>usergroup_content</usergroupcontent>
         <usergroups_services>usergroups_services</usergroups_services>
         <users>users</users>
     </TABLENAME>
diff --git a/core/xml/config.xml.default b/core/xml/config.xml.default
index da2201fe09b956757a535f80b6faea2c420fc3b7..bebf93b1231cb70b2f87d196e44ca238baab25fd 100755
--- a/core/xml/config.xml.default
+++ b/core/xml/config.xml.default
@@ -19,7 +19,6 @@
         <security>security</security>
         <status>status</status>
         <usergroups>usergroups</usergroups>
-        <usergroupcontent>usergroup_content</usergroupcontent>
         <usergroups_services>usergroups_services</usergroups_services>
         <users>users</users>
     </TABLENAME>
diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql
index c517f2c5ba5eb1aec705b8930058d300b8a179fd..c13d80aa6adee4181f1d61a84642699bddcdfa06 100644
--- a/migration/19.12/1912.sql
+++ b/migration/19.12/1912.sql
@@ -307,6 +307,29 @@ DO $$ BEGIN
 END$$;
 
 
+/* USERGROUP_CONTENT */
+DO $$ BEGIN
+    IF (SELECT count(column_name) from information_schema.columns where table_name = 'usergroup_content' and column_name = 'user_id' and data_type != 'integer') THEN
+        ALTER TABLE usergroup_content ADD COLUMN user_id_tmp integer;
+        UPDATE usergroup_content set user_id_tmp = (select id FROM users where users.user_id = usergroup_content.user_id);
+        DELETE FROM usergroup_content WHERE user_id_tmp IS NULL;
+        ALTER TABLE usergroup_content ALTER COLUMN user_id_tmp set not null;
+        ALTER TABLE usergroup_content DROP COLUMN IF EXISTS user_id;
+        ALTER TABLE usergroup_content RENAME COLUMN user_id_tmp TO user_id;
+    END IF;
+END$$;
+DO $$ BEGIN
+    IF (SELECT count(column_name) from information_schema.columns where table_name = 'usergroup_content' and column_name = 'group_id' and data_type != 'integer') THEN
+        ALTER TABLE usergroup_content ADD COLUMN group_id_tmp integer;
+        UPDATE usergroup_content set group_id_tmp = (select id FROM usergroups where usergroups.group_id = usergroup_content.group_id);
+        DELETE FROM usergroup_content WHERE group_id_tmp IS NULL;
+        ALTER TABLE usergroup_content ALTER COLUMN group_id_tmp set not null;
+        ALTER TABLE usergroup_content DROP COLUMN IF EXISTS group_id;
+        ALTER TABLE usergroup_content RENAME COLUMN group_id_tmp TO group_id;
+    END IF;
+END$$;
+
+
 /* REFACTORING DATA */
 DO $$ BEGIN
   IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'usergroups') AND attname = 'enabled') THEN
diff --git a/modules/avis/class/avis_controler_Abstract.php b/modules/avis/class/avis_controler_Abstract.php
index 939fda91c17e06c489d1df2891e193eef2c8c1a8..429ea5d9d61b149a09fa3283399ab493e1a4284a 100755
--- a/modules/avis/class/avis_controler_Abstract.php
+++ b/modules/avis/class/avis_controler_Abstract.php
@@ -227,21 +227,6 @@ abstract class avis_controler_Abstract
         return $tab_userentities;
     }
 
-    public function getGroupAvis()
-    {
-        $db = new Database();
-
-        $stmt = $db->query('SELECT DISTINCT(usergroup_content.group_id),group_desc from usergroups, usergroup_content WHERE usergroups.group_id = usergroup_content.group_id AND usergroup_content.group_id IN (SELECT group_id FROM usergroups_services WHERE service_id = ?)', array('avis_documents'));
-
-        $tab_usergroup = array();
-
-        while ($res = $stmt->fetchObject()) {
-            array_push($tab_usergroup, array('group_id' => $res->group_id, 'group_desc' => $res->group_desc));
-        }
-        //print_r($tab_usergroup);
-        return $tab_usergroup;
-    }
-
     public function getUsersAvis($group_id = null)
     {
         $db = new Database();
@@ -266,21 +251,6 @@ abstract class avis_controler_Abstract
         return $tab_users;
     }
 
-    public function myPosAvis($res_id, $coll_id, $listDiffType)
-    {
-        $db = new Database();
-        $where = 'res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date IS NULL';
-        $order = ' ORDER by listinstance_id ASC';
-        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
-
-        $stmt = $db->query($query, array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
-        $res = $stmt->fetchObject();
-        /* if ($res->item_mode == 'sign'){
-            return $this->nbAvis($res_id, $coll_id);
-        } */
-        return $res->sequence;
-    }
-
     public function saveModelWorkflow($id_list, $workflow, $typeList, $title)
     {
         require_once 'modules/entities/class/class_manage_listdiff.php';
diff --git a/modules/basket/class/class_modules_tools_Abstract.php b/modules/basket/class/class_modules_tools_Abstract.php
index 26bc63469a9a112c2ad2fb6ff12508369cbacd4a..fafc873a24cdd05bed56b942da06ed6bab4e22b1 100755
--- a/modules/basket/class/class_modules_tools_Abstract.php
+++ b/modules/basket/class/class_modules_tools_Abstract.php
@@ -544,14 +544,10 @@ abstract class basket_Abstract extends Database
         $absBasket = false;
 
         if (!$isSecondary) {
-            $stmt = $db->query(
-                "select group_id from "
-                . $_SESSION['tablename']['usergroup_content']
-                . " where user_id = ?",
-                array($userId)
-            );
-            $res = $stmt->fetchObject();
-            $groupId = $res->group_id;
+            $userUse = \User\models\UserModel::getByLogin(['login' => $userId, 'select' => ['id']]);
+            $userGroup = \User\models\UserGroupModel::get(['select' => ['group_id'], 'where' => ['user_id = ?'], 'data' => [$userUse['id']], 'limit' => 1]);
+            $groupUse = \Group\models\GroupModel::getById(['id' => $userGroup['group_id'], 'select' => ['group_id']]);
+            $groupId = $groupUse['group_id'];
         }
 
         // Gets actions of the basket
diff --git a/modules/entities/admin_listmodel.php b/modules/entities/admin_listmodel.php
index 7cfe6791684617200cf057b77971559d6316d654..74deedbbaf07bf678d09ce7a971dad80996cf462 100755
--- a/modules/entities/admin_listmodel.php
+++ b/modules/entities/admin_listmodel.php
@@ -111,26 +111,6 @@ function listmodel_setObjectId(objectId)
         }
     );
 
-}
- 
-function listmodel_open()
-{
-    var main_error = $('main_error'); 
-    
-    // Validate form
-    var valid = listmodel_validate();
-    
-    if(valid == false)
-        return;
-    
-    // Open pop up 
-    window.open(
-        'index.php?display=true&module=entities&page=manage_listmodel',
-        '',
-        'scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes,width=1024,height=650,location=no'
-    );
-                    
-    
 }
 
 function listmodel_validate() {
@@ -260,7 +240,7 @@ if ($mode != 'del') {
     echo $frm;
     include_once 'modules/entities/difflist_display.php';
     $frm = '<p class="buttons" style="text-align:center;margin-top:5px;">';
-    $frm .= '<input type="button" onclick="listmodel_open()" class="button" value="'._MODIFY_LIST.'"';
+    $frm .= '<input type="button" class="button" value="'._MODIFY_LIST.'"';
     $frm .= '</p>';
     $frm .= '</div>';
 
@@ -358,4 +338,4 @@ if ($_REQUEST['mode'] == 'del') {
     $frm .= '</script>';
 }
     
-echo $frm;
\ No newline at end of file
+echo $frm;
diff --git a/modules/entities/class/class_users_entities_Abstract.php b/modules/entities/class/class_users_entities_Abstract.php
index 845c3f27352bb81c9741419255f53fbce926c82a..4193f8658f305000f63b2a5eae75e13c3ed84f7f 100755
--- a/modules/entities/class/class_users_entities_Abstract.php
+++ b/modules/entities/class/class_users_entities_Abstract.php
@@ -35,26 +35,6 @@ require("modules/entities/entities_tables.php");
 abstract class users_entities_Abstract extends functions
 {
 
-    public function service_load_entities($mode)
-    {
-        $db = new Database();
-        $stmt = $db->query("select count(*) as total from ".ENT_ENTITIES." where enabled ='Y'");
-        $nb_total_1 = $stmt->fetchObject();
-        $_SESSION['m_admin']['nbentities']  = $nb_total_1->total;
-
-        if($mode == 'up')
-        {
-            if (($_SESSION['m_admin']['load_entities'] == true || ! isset($_SESSION['m_admin']['load_entities'] )) && $_SESSION['m_admin']['users']['user_id'] <> "superadmin")
-            {
-                $this->load_entities_session($_SESSION['m_admin']['users']['user_id']);
-            }
-        }
-        else
-        {
-            $_SESSION['m_admin']['entity'] = array();
-        }
-    }
-
     /**
     * Loads in the session variables the entities of the user passed in parameter
     *
@@ -81,72 +61,6 @@ abstract class users_entities_Abstract extends functions
         $_SESSION['m_admin']['load_entities']  = false;
     }
 
-    /**
-    * Removes the entity on the tables passed in parameters for the user.
-    *
-    * @param array $tab
-    */
-    public function remove_session($tab)
-    {
-        $tabtmp = array();
-        for($i=0; $i < count($_SESSION['m_admin']['entity']['entities']); $i++)
-        {
-            if( !in_array($_SESSION['m_admin']['entity']['entities'][$i]['ENTITY_ID'], $tab))
-            {
-                array_push($tabtmp, $_SESSION['m_admin']['entity']['entities'][$i]);
-            }
-        }
-
-        $_SESSION['m_admin']['entity']['entities'] = array();
-        $_SESSION['m_admin']['entity']['entities'] = $tabtmp;
-
-    }
-
-    /**
-    * No entity is the primary entity for the user.
-    *
-    */
-    public function erase_primary_entity_session()
-    {
-        for($i=0; $i < count($_SESSION['m_admin']['entity']['entities']); $i++)
-        {
-            $_SESSION['m_admin']['entity']['entities'][$i]["PRIMARY"] = 'N';
-        }
-
-    }
-
-    /**
-    * Set the primary entity for a user in the session variables.
-    *
-    * @param    string  $entity_id entity identifier
-    */
-    public function set_primary_entity_session($entity_id)
-    {
-        for($i=0; $i < count($_SESSION['m_admin']['entity']['entities']); $i++)
-        {
-            if ( $_SESSION['m_admin']['entity']['entities'][$i]["ENTITY_ID"] == $entity_id)
-            {
-                $_SESSION['m_admin']['entity']['entities'][$i]["PRIMARY"] = 'Y';
-                break;
-            }
-        }
-    }
-
-
-    /**
-    * Adds an entity in the session variables related to the user_entities administration
-    *
-    * @param    string  $entity_id entity identifier
-    * @param    string  $role role in the entity (empty by default)
-    * @param    string  $label label of the entity
-    */
-    public function add_usertmp_to_entity_session($entity_id, $role = "", $label)
-    {
-        $tab = array();
-        $tab = array("USER_ID" => "", "ENTITY_ID" => $entity_id , "LABEL" => functions::show_string($label), "PRIMARY" => 'N', "ROLE" => functions::show_string($role) );
-        array_push($_SESSION['m_admin']['entity']['entities'], $tab);
-    }
-
 
     /**
     * Put in an array ($tmparray) the identifiers of all children of an entity
@@ -322,26 +236,6 @@ abstract class users_entities_Abstract extends functions
     }
 
 
-    public function checks_info($mode)
-    {
-        $primary_set = false;
-        if(!empty($_SESSION['m_admin']['entity']['entities'])   )
-        {
-            for($i=0; $i < count($_SESSION['m_admin']['entity']['entities']); $i++)
-            {
-                if($_SESSION['m_admin']['entity']['entities'][$i]['PRIMARY'] == 'Y')
-                {
-                    $primary_set = true;
-                    break;
-                }
-            }
-
-            if ($primary_set == false)
-            {
-                $_SESSION['error'] = _NO_PRIMARY_ENTITY;
-            }
-        }
-    }
     /**
     * Add ou modify users_entities in the database
     *
@@ -412,46 +306,6 @@ abstract class users_entities_Abstract extends functions
         }
     }
 
-    /**
-    * Cleans the listmodels_content table in the database from a given user
-    *   (user_id)
-    *
-    * @param  $userId string  User identifier
-    * @return bool true if the cleaning is complete, false otherwise
-    */
-
-    public function cleanListModelsContent($userId){
-
-        $control = array();
-        if (! isset($userId) || empty($userId)) {
-            $control = array(
-                'status' => 'ko',
-                'value' => '',
-                'error' => _USER_ID_EMPTY,
-            );
-            return $control;
-        }
-
-        $db = new Database();
-        $func = new functions();
-        $query = 'delete from ' . LISTMODELS_CONTENT_TABLE . " where item_id = ?";
-        
-        try{
-            $db->query($query,array($userId));
-            $control = array(
-                'status' => 'ok',
-                'value'  => $userId,
-            );
-        } catch (Exception $e){
-            $control = array(
-                'status' => 'ko',
-                'value'  => '',
-                'error'  => _CANNOT_CLEAN_USERGROUP_CONTENT . ' ' . $userId,
-            );
-        }
-        return $control;
-    }
-
     /**
     * Clear the users add or modification vars
     */
diff --git a/modules/entities/manage_listmodel.php b/modules/entities/manage_listmodel.php
deleted file mode 100755
index e298c82e583fad5fefa1e323498dddddd14fb332..0000000000000000000000000000000000000000
--- a/modules/entities/manage_listmodel.php
+++ /dev/null
@@ -1,1074 +0,0 @@
-<?php
-/**
-* File : manage_listmodel.php.
-*
-* Pop up used to create and modify diffusion lists models
-*
-* @version 1.0
-*
-* @since 06/2006
-*
-* @license GPL
-* @author  Claire Figueras  <dev@maarch.org>
-* @author  Cyril Vazquez  <dev@maarch.org>
-*/
-require_once 'core/class/usergroups_controler.php';
-require_once 'modules/entities/class/class_manage_listdiff.php';
-require_once 'modules/entities/entities_tables.php';
-require_once 'core/core_tables.php';
-
-$core_tools = new core_tools();
-$core_tools->load_lang();
-$func = new functions();
-
-$db = new Database();
-
-$difflist = new diffusion_list();
-$usergroups_controler = new usergroups_controler();
-
-// *****************************************************************************
-// Manage request paramaters
-// *****************************************************************************
-// Origin not used
-$origin = $_REQUEST['origin'];
-
-// Action ?
-if (isset($_GET['action'])) {
-    $action = $_GET['action'];
-} else {
-    $action = false;
-}
-
-// Id ?
-if (isset($_GET['id'])) {
-    $id = $_GET['id'];
-} else {
-    $id = false;
-}
-
-// Rank for remove/move ?
-if (isset($_GET['rank'])) {
-    $rank = $_GET['rank'];
-} else {
-    $rank = false;
-}
-
-// Mode (dest/copy or custom copy mode)
-if (isset($_GET['role']) && !empty($_GET['role'])) {
-    $role_id = $_GET['role'];
-} else {
-    $role_id = false;
-}
-// *****************************************************************************
-// Manage SESSION paramaters
-// *****************************************************************************
-// Object/list type
-$objectType = $_SESSION['m_admin']['entity']['listmodel']['object_type'];
-$objectId = $_SESSION['m_admin']['entity']['listmodel']['object_id'];
-$description = $_SESSION['m_admin']['entity']['listmodel']['description'];
-
-// Load roles
-$difflistType = $difflist->get_difflist_type($objectType);
-$roles = $difflist->get_difflist_type_roles($difflistType);
-$available_roles = $difflist->list_difflist_roles();
-
-if ($difflistType->allow_entities == 'Y') {
-    $allow_entities = true;
-} else {
-    $allow_entities = false;
-}
-
-// Dest user
-if (isset($_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0])
-    && !empty($_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0])) {
-    $dest_is_set = true;
-} else {
-    $dest_is_set = false;
-}
-
-if (isset($_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0])
-    && !empty($_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0])) {
-    $sign_is_set = true;
-} else {
-    $sign_is_set = false;
-}
-
-// 1.4 create indexed array of existing diffusion to search for users/entities easily
-$user_roles = array();
-$entity_roles = array();
-foreach ($roles as $role_id_local => $role_label) {
-    for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id_local]['users']);
-        $i < $l; ++$i
-    ) {
-        $user_id = $_SESSION['m_admin']['entity']['listmodel'][$role_id_local]['users'][$i]['user_id'];
-        $user_roles[$user_id][] = $role_id_local;
-    }
-    for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id_local]['entities']);
-        $i < $l;
-        ++$i
-    ) {
-        $entity_id = $_SESSION['m_admin']['entity']['listmodel'][$role_id_local]['entities'][$i]['entity_id'];
-        $entity_roles[$entity_id][] = $role_id_local;
-    }
-}
-// *****************************************************************************
-// Search functions / filter users and entities avilable for list composition
-// *****************************************************************************
-if (isset($_POST['what_users']) && !empty($_POST['what_users'])) {
-    $_GET['what_users'] = $_POST['what_users'];
-}
-if (isset($_POST['what_services']) && !empty($_POST['what_services'])) {
-    $_GET['what_services'] = $_POST['what_services'];
-}
-if (isset($_REQUEST['no_filter'])) {
-    $_GET['what_users'] = '%';
-    $_GET['what_services'] = '%';
-}
-$users = array();
-$entities = array();
-$PDOarray = array();
-if (isset($_GET['what_users'])
-    && !empty($_GET['what_users'])
-) {
-    $what_users = $func->wash($_GET['what_users'], 'no', '', 'no');
-    $user_expr =
-        ' and ( '
-            .'lower(u.lastname) like lower(:whatUser) '
-            .' or lower(u.firstname) like lower(:whatUser) '
-            .' or lower(u.user_id) like lower(:whatUser)'
-        .')';
-    $PDOarray = array_merge($PDOarray, array(':whatUser' => '%'.$what_users.'%'));
-}
-if (isset($_GET['what_services'])
-    && !empty($_GET['what_services'])
-) {
-    $what_services = addslashes(
-        $func->wash($_GET['what_services'], 'no', '', 'no')
-    );
-    $entity_expr =
-        ' and ('
-            .' lower(e.entity_label) like lower(:whatEntity) '
-            .' or lower(e.entity_id) like lower(:whatEntity)'
-        .')';
-    $PDOarray = array_merge($PDOarray, array(':whatEntity' => '%'.$what_services.'%'));
-}
-$users_query =
-    'select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label '
-    .'FROM '.$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '
-    .ENT_USERS_ENTITIES." ue WHERE u.status <> 'DEL' and u.enabled = 'Y' and"
-    .' e.entity_id = ue.entity_id and u.user_id = ue.user_id and'
-    ." e.enabled = 'Y' and ue.primary_entity='Y' ".$user_expr.$entity_expr
-    .' order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc';
-
-if ($objectType == 'VISA_CIRCUIT') {
-    $users_query =
-    'select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label '
-    .'FROM '.$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '
-    .ENT_USERS_ENTITIES.' ue, '.USERGROUP_CONTENT_TABLE." uc WHERE u.status <> 'DEL' and u.enabled = 'Y' and"
-    .' e.entity_id = ue.entity_id and u.user_id = ue.user_id and'
-    ." e.enabled = 'Y' and ue.primary_entity='Y' ".$user_expr.$entity_expr
-    ." and u.user_id = uc.user_id AND uc.group_id IN (SELECT group_id FROM usergroups_services WHERE service_id = 'visa_documents')"
-    .' order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc';
-}
-
-if ($user_expr == '' && $entity_expr == '') {
-    //no query
-} else {
-    $stmt = $db->query($users_query, $PDOarray);
-    while ($line = $stmt->fetchObject()) {
-        array_push(
-            $users,
-            array(
-                'ID' => functions::show_string($line->user_id),
-                'PRENOM' => functions::show_string($line->firstname),
-                'NOM' => functions::show_string($line->lastname),
-                'DEP_ID' => functions::show_string($line->entity_id),
-                'DEP' => functions::show_string($line->entity_label),
-            )
-        );
-    }
-}
-
-$entity_query =
-    'select e.entity_id,  e.entity_label FROM '
-        .$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '
-        .ENT_USERS_ENTITIES." ue WHERE u.status <> 'DEL' and u.enabled = 'Y'"
-        .'and  e.entity_id = ue.entity_id and u.user_id = ue.user_id and '
-        ."e.enabled = 'Y' ".$user_expr.$entity_expr
-        .' group by e.entity_id, e.entity_label order by e.entity_label asc';
-
-if ($user_expr == '' && $entity_expr == '') {
-    //no query
-} else {
-    $stmt = $db->query($entity_query, $PDOarray);
-    while ($line = $stmt->fetchObject()) {
-        array_push(
-            $entities,
-            array(
-                'ID' => functions::show_string($line->entity_id),
-                'DEP' => functions::show_string($line->entity_label),
-            )
-        );
-    }
-}
-//****************************************************************************************
-// RELOAD PARENT ID VALIDATION OF LIST
-//****************************************************************************************
-if (isset($_POST['valid'])) {
-    $_SESSION['popup_suite'] = true;
-    // Reload caller with new list in session?>
-    <script type="text/javascript">
-        window.parent.opener.location.reload();
-        self.close();
-    </script><?php
-    exit;
-}
-//****************************************************************************************
-// SWITCH ON ACTION REQUEST
-//****************************************************************************************
-switch ($action) {
-// ADDS
-//***************************************************************************************
-// Add USER AS dest/copy/custom mode
-case 'add_user':
-    $stmt = $db->query(
-        'SELECT u.firstname, u.lastname, e.entity_id, e.entity_label '
-        .' FROM '.USERS_TABLE.' u '
-        .' LEFT JOIN '.ENT_USERS_ENTITIES.' ue ON u.user_id = ue.user_id '
-        .' LEFT JOIN '.ENT_ENTITIES.' e ON ue.entity_id = e.entity_id'
-        ." WHERE u.user_id= ? and ue.primary_entity = 'Y'", array($id)
-    );
-    $line = $stmt->fetchObject();
-
-    $visible = 'Y';
-    if (!isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'])) {
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array();
-    } else {
-        if ($lastUser = end($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'])) {
-            $visible = $lastUser['visible'];
-        }
-    }
-
-    // If dest is set && role is dest, move current dest to copy (legacy)
-    if ($role_id == 'dest' && $dest_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel']['copy']['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel']['copy']['users'] = array();
-        }
-
-        $old_dest = $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'];
-        if (!in_array('copy', $user_roles[$old_dest])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel']['copy']['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]);
-    }
-
-    // If sign is set && role is sign, move current sign to visa (legacy)
-    if ($role_id == 'sign' && $sign_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel']['visa']['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel']['visa']['users'] = array();
-        }
-
-        $old_dest = $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'];
-        if (!in_array('visa', $user_roles[$old_dest])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel']['visa']['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]);
-    }
-
-    array_push(
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-        array(
-            'user_id' => functions::show_string($id),
-            'firstname' => functions::show_string($line->firstname),
-            'lastname' => functions::show_string($line->lastname),
-            'entity_id' => functions::show_string($line->entity_id),
-            'entity_label' => functions::show_string($line->entity_label),
-            'visible' => $visible,
-        )
-    );
-    $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']
-    );
-    break;
-
-// ADD ENTITY AS copy/custom mode
-case 'add_entity':
-    $stmt = $db->query(
-        'SELECT entity_id, entity_label FROM '.ENT_ENTITIES
-        .' WHERE entity_id = ?', array($id)
-    );
-    $line = $stmt->fetchObject();
-    $visible = 'Y';
-    if (!isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'])) {
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'] = array();
-    } else {
-        if ($lastEntity = end($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'])) {
-            $visible = $lastEntity['visible'];
-        }
-    }
-    array_push(
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'],
-        array(
-            'entity_id' => $db->show_string($id),
-            'entity_label' => $db->show_string($line->entity_label),
-            'visible' => $visible,
-        )
-    );
-    break;
-
-// REMOVE
-//***************************************************************************************
-// Remove USER
-case 'remove_user':
-    if ($rank !== false && $id && $role_id
-        && $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'] == $id
-    ) {
-        $visible = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['visible'];
-        unset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]);
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']
-        );
-        if (isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank])) {
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['visible'] = $visible;
-        }
-        if ($role_id == 'dest') {
-            $dest_is_set = false;
-        }
-        if ($role_id == 'sign') {
-            $sign_is_set = false;
-        }
-    }
-    break;
-
-// Remove ENTITY
-case 'remove_entity':
-    if ($rank !== false && $id && $role_id
-        && $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]['entity_id'] == $id
-    ) {
-        $visible = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]['visible'];
-        unset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]);
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities']
-        );
-        if (isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank])) {
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]['visible'] = $visible;
-        }
-    }
-    break;
-
-// MOVE
-//***************************************************************************************
-case 'dest_to_copy':
-    if ($dest_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel']['copy']['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel']['copy']['users'] = array();
-        }
-
-        $old_dest = $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'];
-        if (!in_array('copy', $user_roles[$old_dest])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel']['copy']['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]);
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel']['dest']['users']
-        );
-        $dest_is_set = false;
-    }
-    break;
-
-case 'copy_to_dest':
-    if ($dest_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array();
-        }
-        $old_dest = $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'];
-        if (!in_array('copy', $user_roles[$old_dest])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]);
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel']['dest']['users']
-        );
-    }
-    if (isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'])
-        && !empty($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'])
-    ) {
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['user_id'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'];
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['firstname'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['firstname'];
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['lastname'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['lastname'];
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_id'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['entity_id'];
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['entity_label'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['entity_label'];
-        $_SESSION['m_admin']['entity']['listmodel']['dest']['users'][0]['visible'] = 'Y';
-        unset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]);
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']
-        );
-        $dest_is_set = true;
-    }
-    break;
-case 'sign_to_visa':
-    if ($sign_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel']['visa']['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel']['visa']['users'] = array();
-        }
-
-        $old_dest = $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'];
-        if (!in_array('visa', $user_roles[$old_dest])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel']['visa']['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]);
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel']['sign']['users']
-        );
-        $sign_is_set = false;
-    }
-    break;
-
-case 'visa_to_sign':
-    if ($sign_is_set) {
-        if (!isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'])) {
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array();
-        }
-        $old_sign = $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'];
-        if (!in_array('visa', $user_roles[$old_sign])) {
-            array_push(
-                $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-                array(
-                    'user_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'],
-                    'firstname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['firstname'],
-                    'lastname' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['lastname'],
-                    'entity_id' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_id'],
-                    'entity_label' => $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_label'],
-                    'visible' => 'Y',
-                )
-            );
-        }
-        unset($_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]);
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel']['sign']['users']
-        );
-    }
-    if (isset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'])
-        && !empty($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'])
-    ) {
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['user_id'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['user_id'];
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['firstname'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['firstname'];
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['lastname'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['lastname'];
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_id'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['entity_id'];
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['entity_label'] = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['entity_label'];
-        $_SESSION['m_admin']['entity']['listmodel']['sign']['users'][0]['visible'] = 'Y';
-        unset($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]);
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'] = array_values(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']
-        );
-        $sign_is_set = true;
-    }
-    break;
-case 'move_user_down':
-    $downUser =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-            $rank,
-            1,
-            $preserve_keys = true
-        );
-    $newRank = $rank + 1;
-    $upUser =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-            $newRank,
-            1,
-            $preserve_keys = true
-        );
-    if ($upUser[0] && $downUser[0]) {
-        // Switch visible values
-        $downUserVisible = $downUser[0]['visible'];
-        $upUserVisible = $upUser[0]['visible'];
-        $upUser[0]['visible'] = $downUserVisible;
-        $downUser[0]['visible'] = $upUserVisible;
-        // Switch positions
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank] = $upUser[0];
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$newRank] = $downUser[0];
-    }
-    break;
-
-case 'move_entity_down':
-    $downEntity =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'],
-            $rank,
-            1,
-            $preserve_keys = true
-        );
-    $newRank = $rank + 1;
-    $upEntity =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'],
-            $newRank,
-            1,
-            $preserve_keys = true
-        );
-    if ($upEntity[0] && $downEntity[0]) {
-        // Switch visible values
-        $downEntityVisible = $downEntity[0]['visible'];
-        $upEntityVisible = $upEntity[0]['visible'];
-        $upEntity[0]['visible'] = $downEntityVisible;
-        $downEntity[0]['visible'] = $upEntityVisible;
-        // Switch positions
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank] = $upEntity[0];
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$newRank] = $downEntity[0];
-    }
-    break;
-
-case 'move_user_up':
-    $upUser =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-            $rank,
-            1,
-            $preserve_keys = true
-        );
-    $newRank = $rank - 1;
-    $downUser =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'],
-            $newRank,
-            1,
-            $preserve_keys = true
-        );
-    if ($upUser[0] && $downUser[0]) {
-        // Switch visible values
-        $downUserVisible = $downUser[0]['visible'];
-        $upUserVisible = $upUser[0]['visible'];
-        $upUser[0]['visible'] = $downUserVisible;
-        $downUser[0]['visible'] = $upUserVisible;
-        // Switch positions
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank] = $downUser[0];
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$newRank] = $upUser[0];
-    }
-    break;
-
-case 'move_entity_up':
-    $upEntity =
-    array_splice(
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'],
-        $rank,
-        1,
-        $preserve_keys = true
-    );
-    $newRank = $rank - 1;
-    $downEntity =
-        array_splice(
-            $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'],
-            $newRank,
-            1,
-            $preserve_keys = true
-        );
-
-    if ($upEntity[0] && $downEntity[0]) {
-        // Switch visible values
-        $downEntityVisible = $downEntity[0]['visible'];
-        $upEntityVisible = $upEntity[0]['visible'];
-        $upEntity[0]['visible'] = $downEntityVisible;
-        $downEntity[0]['visible'] = $upEntityVisible;
-        // Switch positions
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank] = $downEntity[0];
-        $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$newRank] = $upEntity[0];
-    }
-    break;
-
-// VISIBLE
-//***************************************************************************************
-case 'make_user_visible':
-    $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['visible'] = 'Y';
-    break;
-
-case 'make_user_unvisible':
-    $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$rank]['visible'] = 'N';
-    break;
-
-case 'make_entity_visible':
-    $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]['visible'] = 'Y';
-    break;
-
-case 'make_entity_unvisible':
-    $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$rank]['visible'] = 'N';
-    break;
-// END SWITCH ACTION
-}
-
-// 1.4 create indexed array of existing diffusion to search for users/entities easily
-$user_roles = array();
-$entity_roles = array();
-foreach ($roles as $role_id => $role_label) {
-    for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']);
-        $i < $l; ++$i
-    ) {
-        $user_id = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$i]['user_id'];
-        $user_roles[$user_id][] = $role_id;
-    }
-    for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities']);
-        $i < $l;
-        ++$i
-    ) {
-        $entity_id = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$i]['entity_id'];
-        $entity_roles[$entity_id][] = $role_id;
-    }
-}
-
-$core_tools->load_html();
-$core_tools->load_header(_LISTMODEL);
-$time = $core_tools->get_session_time_expire();
-$link = $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=manage_listmodel';
-if ($onlyCc) {
-    $link .= '&only_cc';
-}
-if ($noDelete) {
-    $link .= '&no_delete';
-}
-
-$linkwithwhat =
-    $link
-    .'&what_users='.$whatUsers
-    .'&what_services='.$whatServices;
-//******************************************************************************
-// DISPLAY EXISTING LIST
-//******************************************************************************
-?>
-<body onload="setTimeout(window.close, <?php echo $time; ?>*60*1000);">
-    <script type="text/javascript">
-        function add_user(id) {
-            var user_id = $('user_id_' + id).value;
-            var role_select = $('user_role_' + id);
-			var role = role_select.options[role_select.selectedIndex].value;
-            goTo('<?php echo $linkwithwhat; ?>&action=add_user&id='+user_id+'&role='+role);
-        }
-        function add_entity(id) {
-            var entity_id = $('entity_id_' + id).value;
-            var role_select = $('entity_role_' + id);
-			var role = role_select.options[role_select.selectedIndex].value;
-            goTo('<?php echo $linkwithwhat; ?>&action=add_entity&id='+entity_id+'&role='+role);
-        }
-    </script>
-    <div id="diff_list" class="block" align="center">
-        <h2><?php 
-            echo _DIFFUSION_LIST.' - ';
-            functions::xecho($description);
-        ?></h2><?php 
-        //**************************************************************************
-        // DEST USER
-        //**************************************************************************
-        if (1 == 2 && isset($_SESSION['m_admin']['entity']['listmodel']['dest']['user_id'])
-            && !empty($_SESSION['m_admin']['entity']['listmodel']['dest']['user_id'])
-        ) {
-            ?>
-        <h3 class="sstit"><?php echo _PRINCIPAL_RECIPIENT; ?></h3>
-        <table cellpadding="0" cellspacing="0" border="0" class="listing spec">
-            <tr>
-                <td>
-                    <i class="fa fa-user fa-2x" title="<?php echo _USER; ?>"></i>
-                </td>
-                <td><?php
-                if ($_SESSION['m_admin']['entity']['listmodel']['dest']['visible'] == 'Y') {
-                    ?>
-                    <i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i> <?php
-                } ?>
-                </td>
-                <td><?php functions::xecho($_SESSION['m_admin']['entity']['listmodel']['dest']['lastname']).' '.$_SESSION['m_admin']['entity']['listmodel']['dest']['firstname']; ?></td>
-                <td><?php functions::xecho($_SESSION['m_admin']['entity']['listmodel']['dest']['entity_label']); ?></td>
-                <td class="action_entities" style="width:5%;"><!-- Remove dest -->
-                    <a href="<?php echo $linkwithwhat; ?>&action=remove_dest"><i class="fa fa-times fa-lg"></i></a>
-                </td>
-                <td class="action_entities" style="width:15%;"><!-- Move dest to copy -->
-                    <a href="<?php echo $linkwithwhat; ?>&action=dest_to_copy&role=copy" ><i class="fa fa-arrow-down fa-2x"></i><?php echo _TO_CC; ?></a>
-                </td>
-            </tr>
-        </table><?php
-        } ?>
-        <br/> <?php 
-        //**************************************************************************
-        // OTHER ROLES
-        //**************************************************************************
-        foreach ($roles as $role_id => $role_label) {
-            if (count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']) > 0
-             || count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities']) > 0
-            ) {
-                ?>
-                <h3 class="sstit"  style="font-size:1.5em; text-align:left; margin-left:100px; margin-bottom: -10px"><?php functions::xecho($role_label); ?></h3>
-                <table cellpadding="0" cellspacing="0" border="0" class="listing liste_diff spec"><?php
-                //**************************************************************************
-                // OTHER ROLE USERS
-                //**************************************************************************
-                $color = ' class="col"';
-                for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['users']);
-                    $i < $l;
-                    ++$i
-                ) {
-                    $user = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['users'][$i];
-
-                    if ($color == ' class="col"') {
-                        $color = '';
-                    } else {
-                        $color = ' class="col"';
-                    } ?>
-                    <tr <?php echo $color; ?> >
-                        <td style="width:5%;">
-                            <i class="fa fa-user fa-2x" title="<?php echo _USER.' '.$role_label; ?>"></i>
-                        </td>
-                        <td style="width:5%;"><?php
-                        if ($user['visible'] == 'Y') {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=make_user_unvisible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
-                                <i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i>
-                            </a><?php
-                        } else {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=make_user_visible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
-                                <i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE; ?>"></i>
-                            </a><?php
-                        } ?>
-                        </td>
-                        <td ><?php functions::xecho($user['lastname'].' '.$user['firstname']); ?></td>
-                        <td><?php functions::xecho($user['entity_label']); ?></td>
-                        <td class="action_entities" style="width:5%;"><!-- Remove user -->
-                            <a href="<?php functions::xecho($linkwithwhat); ?>&action=remove_user&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>&id=<?php functions::xecho($user['user_id']); ?>"><i class="fa fa-times fa-lg" title="<?php echo _DEL_USER_LISTDIFF; ?>"></i></a>
-                        </td>
-                        <td class="action_entities" style="width:15%;"><!-- Switch copy to dest --><?php
-                        if ($role_id == 'dest' && isset($roles['copy'])) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=dest_to_copy&role=copy" ><i class="fa fa-arrow-down"></i><?php echo _TO_CC; ?></a><?php
-                        } elseif ($role_id == 'sign' && isset($roles['visa'])) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=sign_to_visa&role=visa" ><i class="fa fa-arrow-up"></i><?php echo _VISA_USER; ?></a><?php
-                        } elseif ($role_id == 'copy' && isset($roles['dest'])) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=copy_to_dest&role=copy&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-up"></i><?php echo _TO_DEST; ?></a><?php
-                        } elseif ($role_id == 'visa' && isset($roles['sign'])) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=visa_to_sign&role=visa&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-down"></i><?php echo _TO_SIGN; ?></a><?php
-                        } else {
-                            echo '&nbsp;';
-                        } ?>
-                        </td>
-                        <td class="action_entities" style="width:5%;"><!-- Move up in list --><?php 
-                        if ($i > 0) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=move_user_up&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-up"></i></a><?php
-                        } ?>
-                        </td>
-                        <td class="action_entities" style="width:5%;"><!-- Move down in list --><?php 
-                        if ($i < $l - 1) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=move_user_down&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-down"></i></a><?php
-                        } ?>
-                        </td>
-                    </tr> <?php
-                }
-                //**************************************************************************
-                // OTHER ROLE ENTITIES
-                //**************************************************************************
-                for ($i = 0, $l = count($_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities']);
-                    $i < $l;
-                    ++$i
-                ) {
-                    $entity = $_SESSION['m_admin']['entity']['listmodel'][$role_id]['entities'][$i];
-                    if ($color == ' class="col"') {
-                        $color = '';
-                    } else {
-                        $color = ' class="col"';
-                    } ?>
-                    <tr <?php echo $color; ?> >
-                        <td style="width:5%;">
-                            <i class="fa fa-sitemap fa-2x" title="<?php echo _ENTITY.' '.$role_label; ?>"></i> 
-                        </td>
-                        <td style="width:5%;"><?php
-                        if ($entity['visible'] == 'Y') {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=make_entity_unvisible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
-                                <i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i>
-                            </a><?php
-                        } else {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=make_entity_visible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
-                                <i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE; ?>"></i>
-                            </a><?php
-                        } ?>
-                        </td>
-                        <td ><?php functions::xecho($entity['entity_id']); ?></td>
-                        <td ><?php functions::xecho($entity['entity_label']); ?></td>
-                        <td class="action_entities">
-                            <a href="<?php echo $linkwithwhat; ?>&action=remove_entity&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>&id=<?php functions::xecho($entity['entity_id']); ?>" >
-                                <i class="fa fa-times fa-lg" title="<?php echo _DEL_ENTITY_LISTDIFF; ?>"></i>
-                            </a>
-                        </td>
-                        <td class="action_entities">&nbsp;</td>
-                        <td class="action_entities"><!-- Move up in list --><?php 
-                        if ($i > 0) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=move_entity_up&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-up"></i></a><?php
-                        } ?>
-                        </td>
-                        <td class="action_entities"><!-- Move down in list --><?php 
-                        if ($i < $l - 1) {
-                            ?>
-                            <a href="<?php echo $linkwithwhat; ?>&action=move_entity_down&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>" ><i class="fa fa-arrow-down"></i></a><?php
-                        } ?>
-                        </td>
-                    </tr><?php
-                } ?>
-                </table>
-                <br/><?php
-            }
-        }
-        //******************************************************************************
-        // ACTIONS BUTTONS
-        //******************************************************************************?>      
-        <form name="pop_diff" method="post" >
-            <div align="center">
-                <input align="middle" type="submit" value="<?php echo _VALIDATE; ?>" class="button" name="valid"  />
-                <input align="middle" type="button" value="<?php echo _CANCEL; ?>"  onclick="self.close();" class="button"/>
-            </div>
-        </form>
-        <br/>
-        <br/><?php
-
-        //******************************************************************************
-        // LIST OF AVAILABLE ENTITIES / USERS
-        //******************************************************************************?>
-        <hr align="center" color="#6633CC" size="5" width="60%">
-        <div align="center">
-            <form action="#" name="search_diff_list" >
-                <input type="hidden" name="display" value="true" />
-                <input type="hidden" name="module" value="entities" />
-                <input type="hidden" name="page" value="manage_listmodel" />
-                <input type="hidden" name="origin" id="origin" value="<?php functions::xecho($origin); ?>" />
-                <table cellpadding="2" cellspacing="2" border="0">
-                    <tr>
-                        <th>
-                            <label for="what_users" class="bold"><?php echo _USER; ?></label>
-                        </th>
-                        <th>
-                            <input name="what_users" id="what_users" type="text" <?php if (isset($_GET['what_users'])) {
-            echo "value ='".functions::xssafe($_GET['what_users'])."'";
-        } ?> />
-                        </th>
-                    </tr>
-                    <tr>
-                        <th>
-                            <label for="what_services" class="bold"><?php echo _DEPARTMENT; ?></label>
-                        </th>
-                        <th>
-                            <input name="what_services" id="what_services" type="text" <?php if (isset($_GET['what_services'])) {
-            echo "value ='".functions::xssafe($_GET['what_services'])."'";
-        } ?>/>
-                        </th>
-                    </tr>
-                    <tr>
-						<th>
-							<label for="no_filter" class="bold">&nbsp;</label>
-						</th>
-						<th>
-							<input class="button" name="no_filter" id="no_filter" type="button" onclick="$('what_services').value='';$('what_users').value='';" value="<?php echo _NO_FILTER; ?>"/>
-						</th>
-					</tr>
-                </table>
-            </form>     
-        </div> 
-        <script type="text/javascript">
-            repost('<?php echo $link; ?>',new Array('diff_list_items'),new Array('what_users','what_services'),'keyup',250);
-            repost('<?php echo $link; ?>',new Array('diff_list_items'),new Array('no_filter'), 'click',250);
-        </script>
-        <br/>
-        <div id="diff_list_items"> <?php
-        //******************************************************************************
-        // LIST OF AVAILABLE USERS
-        //******************************************************************************
-        if (count($users) > 0) {
-            ?> 
-            <div align="center">
-                <h2 class="tit"><?php echo _USERS_LIST; ?></h2>
-                <table cellpadding="0" cellspacing="0" border="0" class="listing spec">
-                    <thead>
-                        <tr>
-                            <th ><?php echo _LASTNAME.' '._FIRSTNAME; ?></th>
-                            <th><?php echo _DEPARTMENT; ?></th>
-                            <th>&nbsp;</th>
-                        </tr>
-                    </thead><?php 
-                    $color = ' class="col"';
-            //print_r($roles);
-            foreach ($available_roles as $id => $label) {
-                $available_roles_ids[] = $id;
-            }
-            $usersListDiff = array();
-            foreach ($user_roles as $key => $value) {
-                $usersListDiff[] = $key;
-            }
-
-            for ($j = 0, $m = count($users);
-                        $j < $m;
-                        ++$j
-                    ) {
-                $user_id = $users[$j]['ID'];
-                $possible_roles = array();
-
-                if (!in_array($user_id, $usersListDiff)) {
-                    foreach ($roles as $role_id => $role_label) {
-                        if (in_array($role_id, $available_roles_ids) || $usergroups_controler->inGroup($users[$j]['ID'], $role_id)) {
-                            $possible_roles[$role_id] = $role_label;
-                        }
-                    }
-                }
-
-                if ($color == ' class="col"') {
-                    $color = '';
-                } else {
-                    $color = ' class="col"';
-                } ?>
-                        <tr <?php echo $color; ?> id="user_<?php functions::xecho($j); ?>">
-                        <td style="width:30%;"><?php functions::xecho($users[$j]['NOM'].' '.$users[$j]['PRENOM']); ?></td>
-                        <td style="width:50%;"><?php functions::xecho($users[$j]['DEP']); ?></td>
-                        <td class="action_entities" style="width:20%;text-align:center;"><?php
-                        if (count($possible_roles) > 0) {
-                            ?>
-                            <input type="hidden" id="user_id_<?php functions::xecho($j); ?>" value="<?php functions::xecho($users[$j]['ID']); ?>" />
-                            <select name="role" id="user_role_<?php functions::xecho($j); ?>" style="width:60%;"><?php
-                            foreach ($possible_roles as $role_id => $role_label) {
-                                ?>
-                                <option value="<?php functions::xecho($role_id); ?>"><?php functions::xecho($role_label); ?></option><?php
-                            } ?>
-                            </select>&nbsp;
-                            <span onclick="add_user(<?php functions::xecho($j); ?>);" style="cursor: pointer"/> 
-                                <i class="fa fa-user-plus fa-lg" title="<?php echo _ADD_USER_LISTDIFF; ?>"></i>
-                            </span><?php
-                        } else {
-                            echo _NO_AVAILABLE_ROLE;
-                        } ?>
-                        </td>
-                    </tr><?php
-            } ?>
-                </table>
-                <br/>
-            </div> <?php
-        }
-            //******************************************************************************
-            // LIST OF AVAILABLE ENTITIES
-            //******************************************************************************
-            if (count($entities) > 0) {
-                if ($allow_entities) {
-                    ?>
-                <div align="center"> 
-                    <h2 class="tit"><?php echo _ENTITIES_LIST; ?></h2>
-                    <table cellpadding="0" cellspacing="0" border="0" class="listing spec">
-                        <thead>
-                            <tr>
-                                <th><?php echo _ID; ?></th>
-                                <th><?php echo _DEPARTMENT; ?></th>
-                                <th>&nbsp;</th>
-                            </tr>
-                        </thead><?php 
-                    $color = ' class="col"';
-
-                    $entityListDiff = array();
-                    foreach ($entity_roles as $key => $value) {
-                        $entityListDiff[] = $key;
-                    }
-                    for ($j = 0, $m = count($entities); $j < $m; ++$j) {
-                        $entity_id = $entities[$j]['ID'];
-
-                        // Check if at least one role can be added
-                        $possible_roles = array();
-                        if (!in_array($entity_id, $entityListDiff)) {
-                            foreach ($roles as $role_id => $role_label) {
-                                if ($role_id == 'copy') {
-                                    $possible_roles[$role_id] = $role_label;
-                                }
-                            }
-                        }
-
-                        if ($color == ' class="col"') {
-                            $color = '';
-                        } else {
-                            $color = ' class="col"';
-                        } ?>
-                        <tr <?php echo $color; ?>>
-                            <td style="width:30%;"><?php functions::xecho($entities[$j]['ID']); ?></td>
-                            <td style="width:50%;"><?php functions::xecho($entities[$j]['DEP']); ?></td>
-                            <td class="action_entities" style="width:20%;text-align:center;"><?php
-                            if (count($possible_roles) > 0) {
-                                ?>
-                                <input type="hidden" id="entity_id_<?php functions::xecho($j); ?>" value="<?php functions::xecho($entities[$j]['ID']); ?>" />
-                                <select name="role" id="entity_role_<?php functions::xecho($j); ?>" style="width:60%;"><?php 
-                                foreach ($possible_roles as $role_id => $role_label) {
-                                    ?>
-                                    <option value="<?php functions::xecho($role_id); ?>"><?php functions::xecho($role_label); ?></option><?php
-                                } ?>
-                                </select>&nbsp;
-                                <span onclick="add_entity(<?php functions::xecho($j); ?>);" style="cursor: pointer"/> 
-                                    <i class="fa fa-plus fa-lg" title="<?php echo _ADD_ENTITY_LISTDIFF; ?>"></i>
-                                </span><?php
-                            } else {
-                                echo _NO_AVAILABLE_ROLE;
-                            } ?>               
-                            </td>
-                        </tr> <?php
-                    } ?>
-                    </table>
-                </div><?php
-                }
-            }
-            ?>
-        </div>  
-    </div>
-</body>
-</html>
diff --git a/modules/notifications/batch/basket_event_stack.php b/modules/notifications/batch/basket_event_stack.php
index ca2a6578b3e83d9362ca25029075876843704b48..fd8435b683ff104fd920c5afa0cdb484df4dbc2d 100755
--- a/modules/notifications/batch/basket_event_stack.php
+++ b/modules/notifications/batch/basket_event_stack.php
@@ -62,6 +62,7 @@ while ($state != 'END') {
 
                 $u = 1;
                 while ($line2 = $stmt2->fetchObject()) {
+                    $group = \Group\models\GroupModel::getByGroupId(['groupId' => $line2->group_id, 'select' => ['id']]);
                     if ($notification->diffusion_type == 'groups') {
                         $recipients = array();
                         $recipients = $diffusion_type_controler->getRecipients($notification, '');
@@ -72,9 +73,9 @@ while ($state != 'END') {
                         if (empty($aRecipients)) {
                             $aRecipients = '0=1';
                         }
-                        $stmt3 = $db->query("SELECT usergroup_content.user_id, users.id, users.status FROM usergroup_content, users WHERE group_id = ? and users.status in ('OK','ABS') and usergroup_content.user_id=users.user_id and users.user_id in (?)", array($line2->group_id, $aRecipients));
+                        $stmt3 = $db->query("SELECT users.user_id, users.id, users.status FROM usergroup_content, users WHERE group_id = ? and users.status in ('OK','ABS') and usergroup_content.user_id=users.id and users.user_id in (?)", array($group['id'], $aRecipients));
                     } else {
-                        $stmt3 = $db->query("SELECT usergroup_content.user_id, users.id, users.status FROM usergroup_content, users WHERE group_id = ? and users.status in ('OK','ABS') and usergroup_content.user_id=users.user_id", array($line2->group_id));
+                        $stmt3 = $db->query("SELECT users.user_id, users.id, users.status FROM usergroup_content, users WHERE group_id = ? and users.status in ('OK','ABS') and usergroup_content.user_id=users.id", array($group['id']));
                     }
 
                     $baskets_notif = array();
diff --git a/modules/notifications/diffusion_types/group.php b/modules/notifications/diffusion_types/group.php
index 25c96fe78d73a129c8a92a7bbe7193d457786cb6..0a9933b961a37b0238df0b9af24b2ddd68117c02 100755
--- a/modules/notifications/diffusion_types/group.php
+++ b/modules/notifications/diffusion_types/group.php
@@ -28,8 +28,9 @@ switch ($request) {
         $groups = "'".str_replace(',', "','", $notification->diffusion_properties)."'";
         $query = 'SELECT distinct us.*'
             .' FROM usergroup_content ug '
-            .'	LEFT JOIN users us ON us.user_id = ug.user_id'
-            .' WHERE ug.group_id in ('.$groups.')';
+            .'	LEFT JOIN users us ON us.id = ug.user_id'
+            .'	LEFT JOIN usergroups ON ug.group_id = usergroups.group_id'
+            .' WHERE usergroups.group_id in ('.$groups.')';
         $dbRecipients = new Database();
         $stmt = $dbRecipients->query($query);
         $recipients = array();
@@ -40,10 +41,7 @@ switch ($request) {
 
     case 'attach':
         $groups = "'".str_replace(',', "','", $notification->attachfor_properties)."'";
-        $query = 'SELECT user_id'
-            .' FROM usergroup_content'
-            .' WHERE group_id in ('.$groups.')'
-            .' AND user_id = ?';
+        $query = 'SELECT users.user_id FROM usergroup_content, users, usergroups WHERE usergroup_content.group_id = usergroups.group_id AND users.id = usergroup_content.user_id AND usergroups.group_id in ('.$groups.') AND users.user_id = ?';
         $attach = false;
         $dbAttach = new Database();
         $stmt = $dbAttach->query($query, array($user_id));
diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php
index 9ed5936840cd68a3e9d0e2585564d7dc796b7114..cb97a3aeab4fb4f22a0a068eb3dd14ec25b0e0d7 100755
--- a/modules/visa/class/class_modules_tools_Abstract.php
+++ b/modules/visa/class/class_modules_tools_Abstract.php
@@ -91,176 +91,6 @@ abstract class visa_Abstract extends Database
         $_SESSION['modules_loaded']['visa']['routing_template'] = $routing_template;
     }
 
-    public function getDocsBasket()
-    {
-        require_once 'core/class/class_request.php';
-        $request = new request();
-        $table = $_SESSION['current_basket']['view'];
-        $select[$table] = array();
-        array_push(
-            $select[$table],
-            'res_id',
-            'status',
-            'category_id as category_img',
-                        'contact_firstname',
-            'contact_lastname',
-            'contact_society',
-            'user_lastname',
-                        'user_firstname',
-            'priority',
-            'creation_date',
-            'admission_date',
-            'subject',
-                        'process_limit_date',
-            'entity_label',
-            'dest_user',
-            'category_id',
-            'type_label',
-                        'exp_user_id',
-            'doc_custom_n1 as count_attachment',
-            'alt_identifier',
-            'is_multicontacts',
-            'locker_user_id',
-            'locker_time'
-        );
-
-        $where_tab = array();
-
-        // $_SESSION['current_basket']['last_query']['select'] = $select;
-        // $_SESSION['current_basket']['last_query']['where'] = $where;
-        // $_SESSION['current_basket']['last_query']['arrayPDO'] = $arrayPDO;
-        // $_SESSION['current_basket']['last_query']['orderstr'] = $orderstr;
-        // $_SESSION['current_basket']['last_query']['limit'] = $_SESSION['config']['databasesearchlimit'];
-
-        //From basket
-        if (!empty($_SESSION['current_basket']['last_query']['where'])) {
-            $where_tab[] = stripslashes($_SESSION['current_basket']['last_query']['where']); //Basket clause
-        } elseif (!empty($_SESSION['current_basket']['clause'])) {
-            $where_tab[] = stripslashes($_SESSION['current_basket']['clause']); //Basket clause
-        }
-
-        //Order
-        $orderstr = 'order by creation_date desc';
-        if (!empty($_SESSION['current_basket']['last_query']['orderstr'])) {
-            $orderstr = $_SESSION['current_basket']['last_query']['orderstr'];
-        } elseif (isset($_SESSION['last_order_basket'])) {
-            $orderstr = $_SESSION['last_order_basket'];
-        }
-
-        //Request
-        $where = implode(' and ', $where_tab);
-        $tab = $request->PDOselect(
-            $select,
-            $where,
-            array(),
-            $orderstr,
-            $_SESSION['config']['databasetype'],
-            $_SESSION['config']['databasesearchlimit'],
-            false,
-            '',
-            '',
-            '',
-            false,
-            false,
-            'distinct'
-        );
-
-        $tab_docs = array();
-        foreach ($tab as $doc) {
-            array_push($tab_docs, $doc[0]['value']);
-        }
-
-        return $tab_docs;
-    }
-
-    public function get_rep_path($res_id, $coll_id)
-    {
-        require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php';
-        require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'docservers_controler.php';
-        $docserverControler = new docservers_controler();
-        $sec = new security();
-        $view = $sec->retrieve_view_from_coll_id($coll_id);
-        if (empty($view)) {
-            $view = $sec->retrieve_table_from_coll($coll_id);
-        }
-
-        $db = new Database();
-        $stmt = $db->query(
-            'select docserver_id from res_view_attachments where res_id_master = ?'
-            ."AND status <> 'DEL' order by res_id desc",
-            array($res_id)
-        );
-        while ($res = $stmt->fetchObject()) {
-            $docserver_id = $res->docserver_id;
-            break;
-        }
-
-        $stmt = $db->query(
-            'select path_template from '.$_SESSION['tablename']['docservers'].' where docserver_id = ?',
-            array($docserver_id)
-        );
-
-        $res = $stmt->fetchObject();
-        $docserver_path = $res->path_template;
-
-        $stmt = $db->query(
-            'select filename, format, path, title, res_id, res_id_version, attachment_type '
-            ."from res_view_attachments where res_id_master = ? AND status <> 'OBS' AND status <> 'SIGN' "
-            ."AND status <> 'DEL' and attachment_type NOT IN "
-            ."('converted_pdf','print_folder') order by creation_date desc",
-            array($res_id)
-        );
-
-        $array_reponses = array();
-        $cpt_rep = 0;
-        while ($res2 = $stmt->fetchObject()) {
-            $filename = $res2->filename;
-            $format = 'pdf';
-            $filename_pdf = str_ireplace($res2->format, $format, $filename);
-            $path = preg_replace('/#/', DIRECTORY_SEPARATOR, $res2->path);
-            //$filename_pdf = str_replace(pathinfo($filename, PATHINFO_EXTENSION), "pdf",$filename);
-            if (file_exists($docserver_path.$path.$filename_pdf)) {
-                $array_reponses[$cpt_rep]['path'] = $docserver_path.$path.$filename_pdf;
-                $array_reponses[$cpt_rep]['title'] = $res2->title;
-                $array_reponses[$cpt_rep]['attachment_type'] = $res2->attachment_type;
-                if ($res2->res_id_version == 0) {
-                    $array_reponses[$cpt_rep]['res_id'] = $res2->res_id;
-                    $array_reponses[$cpt_rep]['is_version'] = 0;
-                } else {
-                    $array_reponses[$cpt_rep]['res_id'] = $res2->res_id_version;
-                    $array_reponses[$cpt_rep]['is_version'] = 1;
-                }
-                if ($res2->res_id_version == 0 && $array_reponses[$cpt_rep]['attachment_type'] == 'outgoing_mail') {
-                    $array_reponses[$cpt_rep]['is_version'] = 2;
-                }
-                ++$cpt_rep;
-            }
-        }
-        /*echo "<pre>";
-        print_r($array_reponses);
-        echo "</pre>";*/
-        return $array_reponses;
-    }
-
-    protected function isSameFile($firstFile, $secondFile)
-    {
-        $nb1 = strrpos($firstFile, '.');
-        $nb2 = strrpos($secondFile, '.');
-
-        return substr($firstFile, 0, $nb1) === substr($secondFile, 0, $nb2);
-    }
-
-    protected function hasSameFileInArray($fileName, $filesArray)
-    {
-        foreach ($filesArray as $tmpFileName) {
-            if ($this->isSameFile($fileName, $tmpFileName)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     public function checkResponseProject($res_id, $coll_id)
     {
         $this->errorMessageVisa = null;
@@ -348,12 +178,6 @@ abstract class visa_Abstract extends Database
         }
     }
 
-    public function deleteWorkflow($res_id, $coll_id)
-    {
-        $db = new Database();
-        $db->query('DELETE FROM visa_circuit WHERE res_id= ? AND coll_id= ?', array($res_id, $coll_id));
-    }
-
     public function nbVisa($res_id, $coll_id)
     {
         $db = new Database();
@@ -461,23 +285,6 @@ abstract class visa_Abstract extends Database
         return $message;
     }
 
-    public function myPosVisa($res_id, $coll_id, $listDiffType)
-    {
-        $db = new Database();
-        $order = 'ORDER by listinstance_id ASC';
-        $where = 'res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date IS NULL';
-        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
-
-        $stmt = $db->query($select, array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
-
-        $res = $stmt->fetchObject();
-        if ($res->item_mode == 'sign') {
-            return $this->nbVisa($res_id, $coll_id);
-        }
-
-        return $res->sequence;
-    }
-
     public function getUsersVis($group_id = null)
     {
         $db = new Database();
@@ -502,21 +309,6 @@ abstract class visa_Abstract extends Database
         return $tab_users;
     }
 
-    public function getGroupVis()
-    {
-        $db = new Database();
-
-        $stmt = $db->query('SELECT DISTINCT(usergroup_content.group_id),group_desc FROM usergroups, usergroup_content WHERE usergroups.group_id = usergroup_content.group_id AND usergroup_content.group_id IN (SELECT group_id FROM usergroups_services WHERE service_id = ?)', array('visa_documents'));
-
-        $tab_usergroup = array();
-
-        while ($res = $stmt->fetchObject()) {
-            array_push($tab_usergroup, array('group_id' => $res->group_id, 'group_desc' => $res->group_desc));
-        }
-
-        return $tab_usergroup;
-    }
-
     public function getEntityVis()
     {
         $db = new Database();
@@ -535,41 +327,6 @@ abstract class visa_Abstract extends Database
         return $tab_userentities;
     }
 
-    public function allUserVised($res_id, $coll_id, $typeList)
-    {
-        $circuit = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT');
-        if (isset($circuit['visa'])) {
-            foreach ($circuit['visa']['users'] as $seq => $step) {
-                if ($step['process_date'] == '') {
-                    return false;
-                }
-            }
-        }
-
-        return true;
-    }
-
-    public function getConsigne($res_id, $coll_id, $userId)
-    {
-        $circuit = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT');
-        if (isset($circuit['visa'])) {
-            foreach ($circuit['visa']['users'] as $seq => $step) {
-                if ($step['user_id'] == $userId) {
-                    return $step['process_comment'];
-                }
-            }
-        }
-        if (isset($circuit['sign'])) {
-            foreach ($circuit['sign']['users'] as $seq => $step) {
-                if ($step['user_id'] == $userId) {
-                    return $step['process_comment'];
-                }
-            }
-        }
-
-        return '';
-    }
-
     public function setStatusVisa($res_id, $coll_id, $inDetails = false)
     {
         $curr_visa_wf = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT');
diff --git a/sql/data_en.sql b/sql/data_en.sql
index 54ab9c2656a476773497cdbf6cc09bc964036baa..4f06f6ebdc46f6d4b7c93e604a32cf98e6ea33a0 100644
--- a/sql/data_en.sql
+++ b/sql/data_en.sql
@@ -395,55 +395,55 @@ select setval('users_id_seq', (select max(id)+1 from users), false);
 
 -- Create USERGROUP_CONTENT
 TRUNCATE TABLE usergroup_content;
-DELETE FROM usergroup_content WHERE user_id = 'rrenaud';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('rrenaud', 'RESPONSABLE', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('rrenaud', 'DIRECTEUR', '');
-DELETE FROM usergroup_content WHERE user_id = 'ccordy';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ccordy', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ssissoko';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ssissoko', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'nnataly';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('nnataly', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ddur';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddur', 'ELU', '');
-DELETE FROM usergroup_content WHERE user_id = 'jjane';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('jjane', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'eerina';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('eerina', 'RESPONSABLE', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('eerina', 'DIRECTEUR', '');
-DELETE FROM usergroup_content WHERE user_id = 'kkaar';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('kkaar', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'bboule';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bboule', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ppetit';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ppetit', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'aackermann';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('aackermann', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ppruvost';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ppruvost', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ttong';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ttong', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'sstar';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('sstar', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'ssaporta';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ssaporta', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ccharles';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ccharles', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'mmanfred';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('mmanfred', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'ddaull';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'RESP_COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'bbain';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bbain', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'jjonasz';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('jjonasz', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'bblier';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bblier', 'COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bblier', 'ADMINISTRATEUR_N1', '');
-DELETE FROM usergroup_content WHERE user_id = 'ggrand';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ggrand', 'ARCHIVISTE', '');
+DELETE FROM usergroup_content WHERE user_id = 1;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (1, 4, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (1, 7, '');
+DELETE FROM usergroup_content WHERE user_id = 2;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (2, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 3;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (3, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 4;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (4, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 5;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (5, 8, '');
+DELETE FROM usergroup_content WHERE user_id = 6;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (6, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 7;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (7, 4, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (7, 7, '');
+DELETE FROM usergroup_content WHERE user_id = 8;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (8, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 9;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (9, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 10;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (10, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 11;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (11, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 12;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (12, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 13;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (13, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 14;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (14, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 15;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (15, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 16;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (16, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 17;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (17, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 18;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 1, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 3, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 19;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (19, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 20;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (20, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 21;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (21, 1, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (21, 5, '');
+DELETE FROM usergroup_content WHERE user_id = 22;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (22, 10, '');
 
 
 -- Create ENTITIES and LISTMODELS
@@ -776,8 +776,8 @@ INSERT INTO users (user_id, password, firstname, lastname, phone, mail, custom_t
 --MAARCH2GEC USER
 DELETE FROM users WHERE user_id = 'cchaplin';
 INSERT INTO users (user_id, password, firstname, lastname, mail, enabled, change_password, status, loginmode) VALUES ('cchaplin', '$2y$10$C.QSslBKD3yNMfRPuZfcaubFwPKiCkqqOUyAdOr5FSGKPaePwuEjG', 'Charlie', 'CHAPLIN', 'info@maarch.org', 'Y', 'N', 'OK', 'restMode');
-DELETE FROM usergroup_content WHERE user_id = 'cchaplin';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('cchaplin', 'MAARCHTOGEC','');
+DELETE FROM usergroup_content WHERE user_id = 24;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (24, 11,'');
 
 ------------
 -- CONTACTS
@@ -977,8 +977,8 @@ Select setval('actions_id_seq', (select max(id)+1 from actions), false);
 -- BANNETTES SECONDAIRES
 TRUNCATE TABLE users_baskets_preferences;
 INSERT INTO users_baskets_preferences (user_serial_id, group_serial_id, basket_id, display)
-SELECT users.id, usergroups.id, groupbasket.basket_id, TRUE FROM users, usergroups, groupbasket, usergroup_content
-WHERE groupbasket.group_id = usergroup_content.group_id AND users.user_id = usergroup_content.user_id AND usergroups.group_id = usergroup_content.group_id
+SELECT usergroup_content.user_id, usergroups.id, groupbasket.basket_id, TRUE FROM usergroups, groupbasket, usergroup_content
+WHERE groupbasket.group_id = usergroups.group_id AND usergroups.id = usergroup_content.group_id
 ORDER BY users.id;
 
 ------------
diff --git a/sql/data_fr.sql b/sql/data_fr.sql
index f307abe882846f56c7ad61e3923f9db943f41094..031119690f014a63fee42258ba405aac9eca066d 100755
--- a/sql/data_fr.sql
+++ b/sql/data_fr.sql
@@ -458,55 +458,55 @@ select setval('users_id_seq', (select max(id)+1 from users), false);
 
 -- Create USERGROUP_CONTENT
 TRUNCATE TABLE usergroup_content;
-DELETE FROM usergroup_content WHERE user_id = 'rrenaud';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('rrenaud', 'RESPONSABLE', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('rrenaud', 'DIRECTEUR', '');
-DELETE FROM usergroup_content WHERE user_id = 'ccordy';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ccordy', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ssissoko';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ssissoko', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'nnataly';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('nnataly', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ddur';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddur', 'ELU', '');
-DELETE FROM usergroup_content WHERE user_id = 'jjane';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('jjane', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'eerina';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('eerina', 'RESPONSABLE', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('eerina', 'DIRECTEUR', '');
-DELETE FROM usergroup_content WHERE user_id = 'kkaar';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('kkaar', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'bboule';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bboule', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ppetit';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ppetit', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'aackermann';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('aackermann', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ppruvost';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ppruvost', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ttong';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ttong', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'sstar';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('sstar', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'ssaporta';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ssaporta', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'ccharles';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ccharles', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'mmanfred';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('mmanfred', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'ddaull';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'RESP_COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ddaull', 'RESPONSABLE', '');
-DELETE FROM usergroup_content WHERE user_id = 'bbain';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bbain', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'jjonasz';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('jjonasz', 'AGENT', '');
-DELETE FROM usergroup_content WHERE user_id = 'bblier';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bblier', 'COURRIER', '');
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('bblier', 'ADMINISTRATEUR_N1', '');
-DELETE FROM usergroup_content WHERE user_id = 'ggrand';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('ggrand', 'ARCHIVISTE', '');
+DELETE FROM usergroup_content WHERE user_id = 1;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (1, 4, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (1, 7, '');
+DELETE FROM usergroup_content WHERE user_id = 2;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (2, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 3;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (3, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 4;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (4, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 5;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (5, 8, '');
+DELETE FROM usergroup_content WHERE user_id = 6;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (6, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 7;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (7, 4, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (7, 7, '');
+DELETE FROM usergroup_content WHERE user_id = 8;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (8, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 9;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (9, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 10;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (10, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 11;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (11, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 12;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (12, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 13;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (13, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 14;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (14, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 15;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (15, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 16;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (16, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 17;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (17, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 18;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 1, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 3, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (18, 4, '');
+DELETE FROM usergroup_content WHERE user_id = 19;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (19, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 20;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (20, 2, '');
+DELETE FROM usergroup_content WHERE user_id = 21;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (21, 1, '');
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (21, 5, '');
+DELETE FROM usergroup_content WHERE user_id = 22;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (22, 10, '');
 
 -- Create ENTITIES and LISTMODELS
 TRUNCATE TABLE entities;
@@ -856,8 +856,8 @@ INSERT INTO users (user_id, password, firstname, lastname, phone, mail, custom_t
 --MAARCH2GEC USER
 DELETE FROM users WHERE user_id = 'cchaplin';
 INSERT INTO users (user_id, password, firstname, lastname, mail, change_password, status, loginmode) VALUES ('cchaplin', '$2y$10$C.QSslBKD3yNMfRPuZfcaubFwPKiCkqqOUyAdOr5FSGKPaePwuEjG', 'Charlie', 'CHAPLIN', 'support@maarch.fr', 'N', 'OK', 'restMode');
-DELETE FROM usergroup_content WHERE user_id = 'cchaplin';
-INSERT INTO usergroup_content (user_id, group_id, role) VALUES ('cchaplin', 'MAARCHTOGEC', '');
+DELETE FROM usergroup_content WHERE user_id = 24;
+INSERT INTO usergroup_content (user_id, group_id, role) VALUES (24, 11, '');
 
 ------------
 -- CONTACTS
@@ -1076,8 +1076,8 @@ Select setval('actions_id_seq', (select max(id)+1 from actions), false);
 -- BANNETTES SECONDAIRES
 TRUNCATE TABLE users_baskets_preferences;
 INSERT INTO users_baskets_preferences (user_serial_id, group_serial_id, basket_id, display)
-SELECT users.id, usergroups.id, groupbasket.basket_id, TRUE FROM users, usergroups, groupbasket, usergroup_content
-WHERE groupbasket.group_id = usergroup_content.group_id AND users.user_id = usergroup_content.user_id AND usergroups.group_id = usergroup_content.group_id
+SELECT usergroup_content.user_id, usergroups.id, groupbasket.basket_id, TRUE FROM usergroups, groupbasket, usergroup_content
+WHERE groupbasket.group_id = usergroups.group_id AND usergroups.id = usergroup_content.group_id
 ORDER BY users.id;
 
 ------------
diff --git a/sql/structure.sql b/sql/structure.sql
index 43666412024de5350d6ad996c84eccbf0593aa3d..2e1c39b172a1071d524676fd3db18bee660c3288 100755
--- a/sql/structure.sql
+++ b/sql/structure.sql
@@ -177,9 +177,9 @@ WITH (OIDS=FALSE);
 
 CREATE TABLE usergroup_content
 (
-  user_id character varying(128) NOT NULL,
-  group_id character varying(32) NOT NULL,
-  "role" character varying(255) DEFAULT NULL::character varying,
+  user_id INTEGER NOT NULL,
+  group_id INTEGER NOT NULL,
+  "role" character varying(255),
   CONSTRAINT usergroup_content_pkey PRIMARY KEY (user_id, group_id)
 )
 WITH (OIDS=FALSE);
diff --git a/src/app/basket/controllers/BasketController.php b/src/app/basket/controllers/BasketController.php
index 0a221614b05cc389d4264a82f20bb77b83cc1bfa..94a47ad06a70e0ad3b4d0898f0c7f1c2040a06bd 100755
--- a/src/app/basket/controllers/BasketController.php
+++ b/src/app/basket/controllers/BasketController.php
@@ -346,8 +346,8 @@ class BasketController
             }
         }
 
-        $users = GroupModel::getUsersByGroupId(['select' => ['id'], 'groupId' => $data['group_id']]);
         $group = GroupModel::getByGroupId(['select' => ['id'], 'groupId' => $data['group_id']]);
+        $users = GroupModel::getUsersById(['select' => ['id'], 'id' => $group['id']]);
         foreach ($users as $user) {
             UserBasketPreferenceModel::create([
                 'userSerialId'  => $user['id'],
diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php
index 7709130ba5da4d7bf6d581131027fd1c37c6e8f3..db80e58d8a2288014f3b447d9be8669a2fcb7ba1 100755
--- a/src/app/group/controllers/GroupController.php
+++ b/src/app/group/controllers/GroupController.php
@@ -12,6 +12,7 @@ use Slim\Http\Request;
 use Slim\Http\Response;
 use SrcCore\controllers\PreparedClauseController;
 use SrcCore\models\ValidatorModel;
+use User\models\UserGroupModel;
 use User\models\UserModel;
 
 class GroupController
@@ -24,7 +25,7 @@ class GroupController
 
         $groups = GroupModel::get();
         foreach ($groups as $key => $value) {
-            $groups[$key]['users'] = GroupModel::getUsersByGroupId(['groupId' => $value['group_id'], 'select' => ['users.user_id', 'users.firstname', 'users.lastname']]);
+            $groups[$key]['users'] = GroupModel::getUsersById(['id' => $value['id'], 'select' => ['users.user_id', 'users.firstname', 'users.lastname']]);
         }
 
         return $response->withJson(['groups' => $groups]);
@@ -129,7 +130,7 @@ class GroupController
 
         $groups = GroupModel::get();
         foreach ($groups as $key => $value) {
-            $groups[$key]['users'] = GroupModel::getUsersByGroupId(['groupId' => $value['group_id'], 'select' => ['users.user_id']]);
+            $groups[$key]['users'] = GroupModel::getUsersById(['id' => $value['id'], 'select' => ['users.user_id']]);
         }
 
         return $response->withJson(['groups' => $groups]);
@@ -148,7 +149,7 @@ class GroupController
 
         $group['security']          = GroupModel::getSecurityByGroupId(['groupId' => $group['group_id']]);
         $group['services']          = GroupModel::getAllServicesByGroupId(['groupId' => $group['group_id']]);
-        $group['users']             = GroupModel::getUsersByGroupId(['groupId' => $group['group_id'], 'select' => ['users.id', 'users.user_id', 'users.firstname', 'users.lastname', 'users.status']]);
+        $group['users']             = GroupModel::getUsersById(['id' => $aArgs['id'], 'select' => ['users.id', 'users.user_id', 'users.firstname', 'users.lastname', 'users.status']]);
         $group['baskets']           = GroupBasketModel::getBasketsByGroupId(['select' => ['baskets.basket_id', 'baskets.basket_name', 'baskets.basket_desc'], 'groupId' => $group['group_id']]);
         $group['canAdminUsers']     = ServiceModel::hasService(['id' => 'admin_users', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin']);
         $group['canAdminBaskets']   = ServiceModel::hasService(['id' => 'admin_baskets', 'userId' => $GLOBALS['userId'], 'location' => 'basket', 'type' => 'admin']);
@@ -192,16 +193,16 @@ class GroupController
         if (empty($newGroup)) {
             return $response->withStatus(400)->withJson(['errors' => 'Group not found']);
         }
-        $oldGroupUsers = GroupModel::getUsersByGroupId(['groupId' => $group['group_id'], 'select' => ['users.user_id']]);
-        $newGroupUsers = GroupModel::getUsersByGroupId(['groupId' => $newGroup['group_id'], 'select' => ['users.user_id']]);
+        $oldGroupUsers = GroupModel::getUsersById(['id' => $aArgs['id'], 'select' => ['users.id']]);
+        $newGroupUsers = GroupModel::getUsersById(['id' => $aArgs['id'], 'select' => ['users.id']]);
         
         //Mapped array to have only user_id
         $oldGroupUsers = array_map(function ($entry) {
-            return $entry['user_id'];
+            return $entry['id'];
         }, $oldGroupUsers);
 
         $newGroupUsers = array_map(function ($entry) {
-            return $entry['user_id'];
+            return $entry['id'];
         }, $newGroupUsers);
 
         $ignoredUsers = [];
@@ -211,7 +212,14 @@ class GroupController
             }
         }
 
-        GroupModel::reassignUsers(['groupId' => $group['group_id'], 'newGroupId' => $newGroup['group_id'], 'ignoredUsers' => $ignoredUsers]);
+        $where = ['group_id = ?'];
+        $data = [$aArgs['groupId']];
+        if (!empty($ignoredUsers)) {
+            $where[] = 'user_id NOT IN (?)';
+            $data[] = $ignoredUsers;
+        }
+
+        UserGroupModel::update(['set' => ['group_id' => $aArgs['newGroupId']], 'where' => $where, 'data' => $data]);
 
         return $response->withJson(['success' => 'success']);
     }
diff --git a/src/app/group/models/GroupModelAbstract.php b/src/app/group/models/GroupModelAbstract.php
index 78de9f5c92aaee03e76719e1fb2542d66236fc3b..0b78516b3dfafc362a05bd6a9c9a8fbbe0db9297 100755
--- a/src/app/group/models/GroupModelAbstract.php
+++ b/src/app/group/models/GroupModelAbstract.php
@@ -134,7 +134,7 @@ abstract class GroupModelAbstract
         DatabaseModel::delete([
             'table'     => 'usergroup_content',
             'where'     => ['group_id = ?'],
-            'data'      => [$group['group_id']]
+            'data'      => [$aArgs['id']]
         ]);
         DatabaseModel::delete([
             'table'     => 'usergroups_reports',
@@ -170,20 +170,20 @@ abstract class GroupModelAbstract
         return true;
     }
 
-    public static function getUsersByGroupId(array $aArgs)
+    public static function getUsersById(array $aArgs)
     {
-        ValidatorModel::notEmpty($aArgs, ['groupId']);
-        ValidatorModel::stringType($aArgs, ['groupId']);
+        ValidatorModel::notEmpty($aArgs, ['id']);
+        ValidatorModel::intVal($aArgs, ['id']);
         ValidatorModel::arrayType($aArgs, ['select']);
 
-        $aUsers = DatabaseModel::select([
+        $users = DatabaseModel::select([
             'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
             'table'     => ['usergroup_content, users'],
-            'where'     => ['group_id = ?', 'usergroup_content.user_id = users.user_id', 'users.status != ?'],
-            'data'      => [$aArgs['groupId'], 'DEL']
+            'where'     => ['group_id = ?', 'usergroup_content.user_id = users.id', 'users.status != ?'],
+            'data'      => [$aArgs['id'], 'DEL']
         ]);
 
-        return $aUsers;
+        return $users;
     }
 
     public static function getAvailableGroupsByUserId(array $aArgs = [])
@@ -211,17 +211,16 @@ abstract class GroupModelAbstract
         return $allGroups;
     }
 
-    public static function getGroupByLogin(array $aArgs = [])
+    public static function getGroupWithUsersGroups(array $aArgs = [])
     {
-        ValidatorModel::notEmpty($aArgs, ['login', 'groupId']);
-        ValidatorModel::stringType($aArgs, ['login']);
-        ValidatorModel::intVal($aArgs, ['groupId']);
+        ValidatorModel::notEmpty($aArgs, ['userId', 'groupId']);
+        ValidatorModel::intVal($aArgs, ['userId', 'groupId']);
 
         $aGroups = DatabaseModel::select([
             'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
             'table'     => ['usergroup_content, usergroups'],
-            'where'     => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?', 'usergroups.id = ?'],
-            'data'      => [$aArgs['login'], $aArgs['groupId']]
+            'where'     => ['usergroup_content.group_id = usergroups.id', 'usergroup_content.user_id = ?', 'usergroup_content.group_id = ?'],
+            'data'      => [$aArgs['userId'], $aArgs['groupId']]
         ]);
 
         return $aGroups;
@@ -349,29 +348,4 @@ abstract class GroupModelAbstract
 
         return true;
     }
-
-    public static function reassignUsers(array $aArgs)
-    {
-        ValidatorModel::notEmpty($aArgs, ['groupId', 'newGroupId']);
-        ValidatorModel::stringType($aArgs, ['groupId', 'newGroupId']);
-        ValidatorModel::arrayType($aArgs, ['ignoredUsers']);
-
-        $where = ['group_id = ?'];
-        $data = [$aArgs['groupId']];
-        if (!empty($aArgs['ignoredUsers'])) {
-            $where[] = 'user_id NOT IN (?)';
-            $data[] = $aArgs['ignoredUsers'];
-        }
-
-        DatabaseModel::update([
-            'table'     => 'usergroup_content',
-            'set'       => [
-                'group_id'  => $aArgs['newGroupId']
-            ],
-            'where'     => $where,
-            'data'      => $data
-        ]);
-
-        return true;
-    }
 }
diff --git a/src/app/group/models/ServiceModelAbstract.php b/src/app/group/models/ServiceModelAbstract.php
index ac115a94ab7200463cba16f868051553e8e1f5b9..8e7fc43730a7cf08c2763116b3fc8e2bbbd7edbe 100755
--- a/src/app/group/models/ServiceModelAbstract.php
+++ b/src/app/group/models/ServiceModelAbstract.php
@@ -284,11 +284,12 @@ abstract class ServiceModelAbstract
         ValidatorModel::notEmpty($aArgs, ['userId']);
         ValidatorModel::stringType($aArgs, ['userId']);
 
+        $user = UserModel::getByLogin(['login' => $aArgs['userId'], 'select' => ['id']]);
         $aServices = DatabaseModel::select([
             'select'    => ['usergroups_services.service_id'],
-            'table'     => ['usergroup_content, usergroups_services'],
-            'where'     => ['usergroup_content.group_id = usergroups_services.group_id', 'usergroup_content.user_id = ?'],
-            'data'      => [$aArgs['userId']]
+            'table'     => ['usergroup_content, usergroups_services, usergroups'],
+            'where'     => ['usergroup_content.group_id = usergroups.id', 'usergroups.group_id = usergroups_services.group_id', 'usergroup_content.user_id = ?'],
+            'data'      => [$user['id']]
         ]);
 
         return $aServices;
diff --git a/src/app/resource/controllers/IndexingController.php b/src/app/resource/controllers/IndexingController.php
index f2a9777d552ddf973556e41e21a87e6a58938ef2..acfc9951ca42c78855cf92f7343d46a91f8cd8d9 100755
--- a/src/app/resource/controllers/IndexingController.php
+++ b/src/app/resource/controllers/IndexingController.php
@@ -61,12 +61,12 @@ class IndexingController
             return $response->withStatus(400)->withJson(['errors' => 'Body resource is empty or not an integer']);
         }
 
-        $group = GroupModel::getById(['id' => $args['groupId'], 'select' => ['group_id', 'can_index', 'indexation_parameters']]);
+        $group = GroupModel::getById(['id' => $args['groupId'], 'select' => ['can_index', 'indexation_parameters']]);
         if (empty($group)) {
             return $response->withStatus(400)->withJson(['errors' => 'Route groupId does not exist']);
         }
 
-        $isUserLinked = UserGroupModel::get(['select' => [1], 'where' => ['user_id = ?', 'group_id = ?'], 'data' => [$GLOBALS['userId'], $group['group_id']]]);
+        $isUserLinked = UserGroupModel::get(['select' => [1], 'where' => ['user_id = ?', 'group_id = ?'], 'data' => [$GLOBALS['id'], $args['groupId']]]);
         if (empty($isUserLinked)) {
             return $response->withStatus(400)->withJson(['errors' => 'Group is not linked to this user']);
         }
@@ -138,7 +138,7 @@ class IndexingController
             return $response->withStatus(400)->withJson(['errors' => 'Param groupId must be an integer val']);
         }
 
-        $indexingParameters = IndexingController::getIndexingParameters(['login' => $GLOBALS['userId'], 'groupId' => $aArgs['groupId']]);
+        $indexingParameters = IndexingController::getIndexingParameters(['userId' => $GLOBALS['id'], 'groupId' => $aArgs['groupId']]);
         if (!empty($indexingParameters['errors'])) {
             return $response->withStatus(403)->withJson($indexingParameters);
         }
@@ -310,7 +310,7 @@ class IndexingController
 
     public static function getIndexingParameters($aArgs = [])
     {
-        $group = GroupModel::getGroupByLogin(['login' => $aArgs['login'], 'groupId' => $aArgs['groupId'], 'select' => ['can_index', 'indexation_parameters']]);
+        $group = GroupModel::getGroupWithUsersGroups(['userId' => $aArgs['userId'], 'groupId' => $aArgs['groupId'], 'select' => ['can_index', 'indexation_parameters']]);
         if (empty($group)) {
             return ['errors' => 'This user is not in this group'];
         }
diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php
index 9ee5ef1087f03bc31231509a4f1572a0d7bb4e07..c1e34f5ac3a4d7265ae2cc99107317fdbfe3ee03 100755
--- a/src/app/resource/controllers/StoreController.php
+++ b/src/app/resource/controllers/StoreController.php
@@ -28,8 +28,7 @@ class StoreController
 {
     public static function storeResource(array $args)
     {
-        ValidatorModel::notEmpty($args, ['encodedFile', 'format', 'doctype', 'modelId']);
-        ValidatorModel::stringType($args, ['format']);
+        ValidatorModel::notEmpty($args, ['doctype', 'modelId']);
         ValidatorModel::intVal($args, ['doctype', 'modelId']);
 
         try {
@@ -123,7 +122,7 @@ class StoreController
 
         $chrono = null;
         if (!empty($args['chrono'])) {
-            $chrono = ChronoModel::getChrono(['id' => $args['category_id'], 'entityId' => $args['destination'], 'typeId' => $args['doctype'], 'resId' => $args['resId']]);
+            $chrono = ChronoModel::getChrono(['id' => $indexingModel['category'], 'entityId' => $args['destination'], 'typeId' => $args['doctype'], 'resId' => $args['resId']]);
         }
 
         if (!empty($args['processLimitDate']) && !empty($args['priority'])) {
diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php
index 1e83bfea170dd6e453a7458c4d2468c853c8f6da..e9bcdb5278faa64eb08542a6e11e1a39d7ec6e96 100755
--- a/src/app/user/controllers/UserController.php
+++ b/src/app/user/controllers/UserController.php
@@ -41,6 +41,7 @@ use SrcCore\models\DatabaseModel;
 use SrcCore\models\PasswordModel;
 use User\models\UserBasketPreferenceModel;
 use User\models\UserEntityModel;
+use User\models\UserGroupModel;
 use User\models\UserModel;
 use User\models\UserSignatureModel;
 
@@ -915,10 +916,10 @@ class UserController
             return $response->withStatus(400)->withJson(['errors' => _USER_ALREADY_LINK_GROUP]);
         }
         if (empty($data['role'])) {
-            $data['role'] = '';
+            $data['role'] = null;
         }
 
-        UserModel::addGroup(['id' => $aArgs['id'], 'groupId' => $data['groupId'], 'role' => $data['role']]);
+        UserGroupModel::create(['user_id' => $aArgs['id'], 'group_id' => $group['id'], 'role' => $data['role']]);
 
         $baskets = GroupBasketModel::get(['select' => ['basket_id'], 'where' => ['group_id = ?'], 'data' => [$data['groupId']]]);
         foreach ($baskets as $basket) {
@@ -952,7 +953,9 @@ class UserController
         if (!empty($error['error'])) {
             return $response->withStatus($error['status'])->withJson(['errors' => $error['error']]);
         }
-        if (empty(GroupModel::getByGroupId(['groupId' => $aArgs['groupId']]))) {
+
+        $group = GroupModel::getByGroupId(['select' => ['id'], 'groupId' => $aArgs['groupId']]);
+        if (empty($group)) {
             return $response->withStatus(400)->withJson(['errors' => 'Group not found']);
         }
 
@@ -961,7 +964,7 @@ class UserController
             $data['role'] = '';
         }
 
-        UserModel::updateGroup(['id' => $aArgs['id'], 'groupId' => $aArgs['groupId'], 'role' => $data['role']]);
+        UserGroupModel::update(['set' => ['role' => $data['role']], 'where' => ['user_id = ?', 'group_id = ?'], 'data' => [$aArgs['id'], $group['id']]]);
 
         $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]);
         HistoryController::add([
@@ -987,7 +990,7 @@ class UserController
             return $response->withStatus(400)->withJson(['errors' => 'Group not found']);
         }
 
-        UserModel::deleteGroup(['id' => $aArgs['id'], 'groupId' => $aArgs['groupId']]);
+        UserGroupModel::delete(['where' => ['user_id = ?', 'group_id = ?'], 'data' => [$aArgs['id'], $group['id']]]);
 
         UserBasketPreferenceModel::delete([
             'where' => ['user_serial_id = ?', 'group_serial_id = ?'],
diff --git a/src/app/user/models/UserGroupModel.php b/src/app/user/models/UserGroupModel.php
index 79fd6d4af7039cd91a42231ad7b36a418aecc896..4d0c8e7eb7cff03e2c30f5dfc23c42f30f16561f 100644
--- a/src/app/user/models/UserGroupModel.php
+++ b/src/app/user/models/UserGroupModel.php
@@ -36,6 +36,24 @@ class UserGroupModel
         return $usersGroups;
     }
 
+    public static function create(array $args)
+    {
+        ValidatorModel::notEmpty($args, ['user_id', 'group_id']);
+        ValidatorModel::intVal($args, ['user_id', 'group_id']);
+        ValidatorModel::stringType($args, ['role']);
+
+        DatabaseModel::insert([
+            'table'         => 'usergroup_content',
+            'columnsValues' => [
+                'user_id'       => $args['user_id'],
+                'group_id'      => $args['group_id'],
+                'role'          => $args['role']
+            ]
+        ]);
+
+        return true;
+    }
+
     public static function update(array $args)
     {
         ValidatorModel::notEmpty($args, ['set', 'where', 'data']);
diff --git a/src/app/user/models/UserModelAbstract.php b/src/app/user/models/UserModelAbstract.php
index 09b85b6b68e31a25bc6a90a0aedd19f65ff11003..567adcb86a4366e8a60571205fcfe6562f973ba1 100755
--- a/src/app/user/models/UserModelAbstract.php
+++ b/src/app/user/models/UserModelAbstract.php
@@ -421,11 +421,13 @@ abstract class UserModelAbstract
         ValidatorModel::notEmpty($aArgs, ['login']);
         ValidatorModel::stringType($aArgs, ['login']);
 
+        $user = UserModel::getByLogin(['login' => $aArgs['login'], 'select' => ['id']]);
+
         $aGroups = DatabaseModel::select([
-            'select'    => ['usergroups.id', 'usergroups.can_index', 'usergroup_content.group_id', 'usergroups.group_desc', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'],
+            'select'    => ['usergroups.id', 'usergroups.can_index', 'usergroups.group_id', 'usergroups.group_desc', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'],
             'table'     => ['usergroup_content, usergroups, security'],
-            'where'     => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?','usergroups.group_id = security.group_id'],
-            'data'      => [$aArgs['login']]
+            'where'     => ['usergroup_content.group_id = usergroups.id', 'usergroup_content.user_id = ?','usergroups.group_id = security.group_id'],
+            'data'      => [$user['id']]
         ]);
 
         return $aGroups;
@@ -482,60 +484,6 @@ abstract class UserModelAbstract
         return false;
     }
 
-    public static function addGroup(array $aArgs)
-    {
-        ValidatorModel::notEmpty($aArgs, ['id', 'groupId']);
-        ValidatorModel::intVal($aArgs, ['id']);
-        ValidatorModel::stringType($aArgs, ['groupId', 'role']);
-
-        $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]);
-        DatabaseModel::insert([
-            'table'         => 'usergroup_content',
-            'columnsValues' => [
-                'user_id'       => $user['user_id'],
-                'group_id'      => $aArgs['groupId'],
-                'role'          => $aArgs['role']
-            ]
-        ]);
-
-        return true;
-    }
-
-    public static function updateGroup(array $aArgs)
-    {
-        ValidatorModel::notEmpty($aArgs, ['id', 'groupId']);
-        ValidatorModel::intVal($aArgs, ['id']);
-        ValidatorModel::stringType($aArgs, ['groupId', 'role']);
-
-        $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]);
-        DatabaseModel::update([
-            'table'     => 'usergroup_content',
-            'set'       => [
-                'role'      => $aArgs['role']
-            ],
-            'where'     => ['user_id = ?', 'group_id = ?'],
-            'data'      => [$user['user_id'], $aArgs['groupId']]
-        ]);
-
-        return true;
-    }
-
-    public static function deleteGroup(array $aArgs)
-    {
-        ValidatorModel::notEmpty($aArgs, ['id', 'groupId']);
-        ValidatorModel::intVal($aArgs, ['id']);
-        ValidatorModel::stringType($aArgs, ['groupId']);
-
-        $user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['user_id']]);
-        DatabaseModel::delete([
-            'table'     => 'usergroup_content',
-            'where'     => ['group_id = ?', 'user_id = ?'],
-            'data'      => [$aArgs['groupId'], $user['user_id']]
-        ]);
-
-        return true;
-    }
-
     public static function hasEntity(array $aArgs)
     {
         ValidatorModel::notEmpty($aArgs, ['id', 'entityId']);
diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php
index e9074268f6cd331b7f90299e86773f36d76dd0da..39263850c4f7b6f020ee585c2422dbc5854735b1 100755
--- a/src/core/controllers/AutoCompleteController.php
+++ b/src/core/controllers/AutoCompleteController.php
@@ -377,7 +377,8 @@ class AutoCompleteController
             'search'        => $data['search'],
             'fields'        => $fields,
             'where'         => [
-                'usergroup_content.group_id = usergroups_services.group_id',
+                'usergroups.group_id = usergroups_services.group_id',
+                'usergroups.id = usergroup_content.group_id',
                 'usergroup_content.user_id = users.user_id',
                 'usergroups_services.service_id in (?)',
                 'users.user_id not in (?)',
@@ -389,7 +390,7 @@ class AutoCompleteController
 
         $users = DatabaseModel::select([
             'select'    => ['DISTINCT users.user_id', 'users.firstname', 'users.lastname'],
-            'table'     => ['users, usergroup_content, usergroups_services'],
+            'table'     => ['users, usergroup_content, usergroups, usergroups_services'],
             'where'     => $requestData['where'],
             'data'      => $requestData['data'],
             'order_by'  => ['users.lastname'],
diff --git a/test/unitTests/app/basket/BasketControllerTest.php b/test/unitTests/app/basket/BasketControllerTest.php
index 49a7b0e1da519d5de40e2a28ab063243c82b8d57..edc126eb4fe3f537694918ca141552fb8bd35f24 100755
--- a/test/unitTests/app/basket/BasketControllerTest.php
+++ b/test/unitTests/app/basket/BasketControllerTest.php
@@ -155,7 +155,7 @@ class BasketControllerTest extends TestCase
         $this->assertInternalType('array', $responseBody->allGroups);
         $this->assertNotNull($responseBody->allGroups);
 
-        $users = \Group\models\GroupModel::getUsersByGroupId(['select' => ['id'], 'groupId' => 'AGENT']);
+        $users = \Group\models\GroupModel::getUsersById(['select' => ['id'], 'id' => 2]);
         $group = \Group\models\GroupModel::getByGroupId(['select' => ['id'], 'groupId' => 'AGENT']);
         foreach ($users as $user) {
             $preference = \User\models\UserBasketPreferenceModel::get([