From c1652169f2f0554e6d4a9234af9f15e193a357ae Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 30 Nov 2016 16:09:59 +0100 Subject: [PATCH 1/4] NEW : Add in export thirdparty for user limit on view thirpdarty to sales team also to subsidiaries --- htdocs/core/modules/modSociete.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 1943e3f7b20..6e55077b19d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; // Export list of contacts and attributes $r++; @@ -311,7 +311,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; // Imports From 1e39805945334723dcf00a910b47e77ca20df42d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Dec 2016 16:14:43 +0100 Subject: [PATCH 2/4] integrate Eldy remarks --- htdocs/core/modules/modSociete.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 6e55077b19d..2de744801f0 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,11 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; + if(!$user->rights->societe->client->voir) { + $subordinatesids = $user->getAllChildIds(); + var_dump($subordinatesids); + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + } // Export list of contacts and attributes $r++; @@ -311,7 +315,10 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; + if(!$user->rights->societe->client->voir) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + } // Imports From a797c45e3bf954e9f5ce528c089e1e1504be2b0c Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Dec 2016 16:28:06 +0100 Subject: [PATCH 3/4] sdf --- htdocs/core/modules/modSociete.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 2de744801f0..f0ea5370c6c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -283,7 +283,6 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; if(!$user->rights->societe->client->voir) { $subordinatesids = $user->getAllChildIds(); - var_dump($subordinatesids); $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; } From a99ac7fb6b0098b1ff2193d28e0aca3ba40b6cc9 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 13 Dec 2016 16:52:49 +0100 Subject: [PATCH 4/4] taking account @eldy remarks --- htdocs/core/modules/modSociete.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 7984ed7f6a1..af4da616ce9 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -282,8 +282,12 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; if(!$user->rights->societe->client->voir) { - $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; } // Export list of contacts and attributes @@ -315,8 +319,12 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; if(!$user->rights->societe->client->voir) { - $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; }