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 17:10:22 +00:00
parent bd272c7bd2
commit 36a9494402
3 changed files with 34 additions and 25 deletions

View File

@ -51,11 +51,11 @@ if (! $sortfield) $sortfield="c.date_creation";
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socidp = $user->societe_id;
} }
else else
{ {
$socid = 0; $socidp = 0;
} }
@ -181,7 +181,7 @@ if ($_GET["id"])
// Propals // Propals
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
$ret=$product->load_stats_propale($socid); $ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal"); $langs->load("propal");
print '<tr><td>'; print '<tr><td>';
@ -198,7 +198,7 @@ if ($_GET["id"])
// Commandes // Commandes
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
$ret=$product->load_stats_commande($socid); $ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders"); $langs->load("orders");
print '<tr><td>'; print '<tr><td>';
@ -215,7 +215,7 @@ if ($_GET["id"])
// Contrats // Contrats
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
{ {
$ret=$product->load_stats_contrat($socid); $ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts"); $langs->load("contracts");
print '<tr><td>'; print '<tr><td>';
@ -232,7 +232,7 @@ if ($_GET["id"])
// Factures // Factures
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$ret=$product->load_stats_facture($socid); $ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills"); $langs->load("bills");
print '<tr><td>'; print '<tr><td>';
@ -254,12 +254,15 @@ if ($_GET["id"])
$sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount, c.ref,"; $sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount, c.ref,";
$sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid"; $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."commandedet as d"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."commandedet as d";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp"; $sql.= " WHERE c.fk_soc = s.idp";
$sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id; $sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id;
if ($socid) if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socidp)
{ {
$sql .= " AND c.fk_soc = $socid"; $sql .= " AND c.fk_soc = $socidp";
} }
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset); $sql.= $db->plimit($conf->liste_limit +1, $offset);

View File

@ -48,10 +48,10 @@ if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef"; if (! $sortfield) $sortfield="f.datef";
// Securite // Securite
$socid = 0; $socidp = 0;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$socid = $user->societe_id; $socidp = $user->societe_id;
} }
@ -186,7 +186,7 @@ if ($_GET["id"] || $_GET["ref"])
// Propals // Propals
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
$ret=$product->load_stats_propale($socid); $ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal"); $langs->load("propal");
print '<tr><td>'; print '<tr><td>';
@ -203,7 +203,7 @@ if ($_GET["id"] || $_GET["ref"])
// Commandes // Commandes
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
$ret=$product->load_stats_commande($socid); $ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders"); $langs->load("orders");
print '<tr><td>'; print '<tr><td>';
@ -220,7 +220,7 @@ if ($_GET["id"] || $_GET["ref"])
// Contrats // Contrats
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
{ {
$ret=$product->load_stats_contrat($socid); $ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts"); $langs->load("contracts");
print '<tr><td>'; print '<tr><td>';
@ -237,7 +237,7 @@ if ($_GET["id"] || $_GET["ref"])
// Factures // Factures
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$ret=$product->load_stats_facture($socid); $ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills"); $langs->load("bills");
print '<tr><td>'; print '<tr><td>';
@ -259,12 +259,15 @@ if ($_GET["id"] || $_GET["ref"])
$sql = "SELECT distinct(s.nom), s.idp, s.code_client, f.facnumber, f.amount as amount,"; $sql = "SELECT distinct(s.nom), s.idp, s.code_client, f.facnumber, f.amount as amount,";
$sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d";
$sql.= " WHERE f.fk_soc = s.idp"; if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.idp";
$sql.= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id; $sql.= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id;
if ($socid) if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socidp)
{ {
$sql .= " AND f.fk_soc = $socid"; $sql .= " AND f.fk_soc = $socidp";
} }
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset); $sql.= $db->plimit($conf->liste_limit +1, $offset);

View File

@ -48,11 +48,11 @@ if (! $sortfield) $sortfield="p.datec";
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socidp = $user->societe_id;
} }
else else
{ {
$socid = 0; $socidp = 0;
} }
@ -177,7 +177,7 @@ if ($_GET["id"])
// Propals // Propals
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
$ret=$product->load_stats_propale($socid); $ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal"); $langs->load("propal");
print '<tr><td>'; print '<tr><td>';
@ -194,7 +194,7 @@ if ($_GET["id"])
// Commandes // Commandes
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
$ret=$product->load_stats_commande($socid); $ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders"); $langs->load("orders");
print '<tr><td>'; print '<tr><td>';
@ -211,7 +211,7 @@ if ($_GET["id"])
// Contrats // Contrats
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
{ {
$ret=$product->load_stats_contrat($socid); $ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts"); $langs->load("contracts");
print '<tr><td>'; print '<tr><td>';
@ -228,7 +228,7 @@ if ($_GET["id"])
// Factures // Factures
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$ret=$product->load_stats_facture($socid); $ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills"); $langs->load("bills");
print '<tr><td>'; print '<tr><td>';
@ -250,12 +250,15 @@ if ($_GET["id"])
$sql = "SELECT distinct(s.nom), s.idp, p.rowid as propalid, p.ref, p.total as amount,"; $sql = "SELECT distinct(s.nom), s.idp, p.rowid as propalid, p.ref, p.total as amount,";
$sql.= $db->pdate("p.datec")." as date, p.fk_statut as statut"; $sql.= $db->pdate("p.datec")." as date, p.fk_statut as statut";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."propaldet as d"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."propaldet as d";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.idp"; $sql.= " WHERE p.fk_soc = s.idp";
$sql.= " AND d.fk_propal = p.rowid AND d.fk_product =".$product->id; $sql.= " AND d.fk_propal = p.rowid AND d.fk_product =".$product->id;
if ($socid) if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socidp)
{ {
$sql .= " AND p.fk_soc = $socid"; $sql .= " AND p.fk_soc = $socidp";
} }
$sql .= " ORDER BY $sortfield $sortorder "; $sql .= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset); $sql.= $db->plimit($conf->liste_limit +1, $offset);