Skip to content

Commit

Permalink
Fix: bad restricted view of company
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Jan 30, 2011
1 parent 8b534d1 commit aa9ccb4
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions htdocs/societe/index.php
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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 @@ -79,18 +79,21 @@

$sql = "SELECT s.rowid, s.client, s.fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;

$result = $db->query($sql);
if ($result)
{
while ($objp = $db->fetch_object($result))
{
if ($objp->client == 1 || $objp->client == 3) $third['customer']++;
if ($objp->client == 2 || $objp->client == 3) $third['prospect']++;
if ($objp->fournisseur) $third['supplier']++;

$total++;
}
while ($objp = $db->fetch_object($result))
{
if ($objp->client == 1 || $objp->client == 3) $third['customer']++;
if ($objp->client == 2 || $objp->client == 3) $third['prospect']++;
if ($objp->fournisseur) $third['supplier']++;

$total++;
}
}
else dol_print_error($db);

Expand Down Expand Up @@ -127,7 +130,9 @@
$sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur,";
$sql.= " s.tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND (";
if (! empty($conf->societe->enabled)) $sql.=" s.client in (1,2,3)";
if (! empty($conf->fournisseur->enabled)) $sql.=" OR s.fournisseur in (1)";
Expand Down

0 comments on commit aa9ccb4

Please sign in to comment.