Skip to content

Commit

Permalink
Merge pull request #6509 from marcosgdf/bug-6507
Browse files Browse the repository at this point in the history
FIX #6507: Statistics counter show wrong total Contract numbers when the user does not have full access
  • Loading branch information
eldy committed Mar 14, 2017
2 parents 53abc32 + e9d5b44 commit 214350a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion htdocs/contrat/class/contrat.class.php
Expand Up @@ -2045,7 +2045,7 @@ function load_state_board()
$sql = "SELECT count(c.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if (!$user->rights->contrat->lire && !$user->societe_id)
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
Expand Down
24 changes: 14 additions & 10 deletions htdocs/projet/class/project.class.php
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014-2017 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1689,17 +1689,21 @@ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
*/
function load_state_board()
{
global $conf;
global $user;

$this->nb=array();

$sql = "SELECT count(u.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as u";
$sql.= " WHERE";
//$sql.= " WHERE u.fk_statut > 0";
//$sql.= " AND employee != 0";
$sql.= " u.entity IN (".getEntity('projet', 1).")";


$sql = "SELECT DISTINCT
count(p.rowid) as nb
FROM ".MAIN_DB_PREFIX."projet AS p LEFT JOIN ".MAIN_DB_PREFIX."societe AS s ON p.fk_soc = s.rowid
LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status AS cls ON p.fk_opp_status = cls.rowid
WHERE p.entity IN (".getEntity('projet', 1).")";

if (! $user->rights->projet->all->lire) {
$projectsListId = $this->getProjectsAuthorizedForUser($user,0,1);
$sql .= "AND p.rowid IN (".$projectsListId.")";
}

$resql=$this->db->query($sql);
if ($resql)
{
Expand Down

0 comments on commit 214350a

Please sign in to comment.