Ajout de la permission "consulter tous les clients" dans le module commercial, afin

qu'un commercial puisse voir que les clients qui lui sont affectés.
This commit is contained in:
Regis Houssin 2006-03-08 15:55:12 +00:00
parent 31a5a97e69
commit 17bab0885c

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -50,12 +51,18 @@ print "</form></table><br />\n";
* Expeditions à valider * Expeditions à valider
*/ */
$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id"; $sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id";
if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 0"; $sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 0";
if ($socidp) if ($socidp)
{ {
$sql .= " AND c.fk_soc = $socidp"; $sql .= " AND c.fk_soc = $socidp";
} }
if (!$user->rights->commercial->client->voir) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -85,8 +92,11 @@ if ($resql)
* Commandes à traiter * Commandes à traiter
*/ */
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp"; $sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 1"; $sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 1";
if (!$user->rights->commercial->client->voir) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.rowid ASC"; $sql.= " ORDER BY c.rowid ASC";
if ( $db->query($sql) ) if ( $db->query($sql) )
@ -124,8 +134,12 @@ print '</td><td valign="top" width="70%">';
/* /*
* Commandes en traitement * Commandes en traitement
*/ */
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; $sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 2"; $sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 2";
if (!$user->rights->commercial->client->voir) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ( $resql ) if ( $resql )
{ {
@ -157,8 +171,11 @@ if ( $resql )
* Expeditions à valider * Expeditions à valider
*/ */
$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id"; $sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 1"; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 1";
if (!$user->rights->commercial->client->voir) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY e.date_expedition DESC"; $sql .= " ORDER BY e.date_expedition DESC";
$sql .= $db->plimit(5, 0); $sql .= $db->plimit(5, 0);