Modif sécurité accés client

This commit is contained in:
Rodolphe Quiedeville 2004-07-29 13:32:29 +00:00
parent fd4be51aa3
commit 81a6799218
3 changed files with 103 additions and 85 deletions

View File

@ -30,6 +30,7 @@ require("../facture.class.php");
/* /*
* Sécurité accés client * Sécurité accés client
*/ */
$socid = $_GET["socid"];
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
@ -130,17 +131,15 @@ if ($mode == 'search')
} }
/* /*
* *
* Mode fiche * Mode fiche
* *
*/ */
if ($_GET["socid"] > 0) if ($socid > 0)
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($_GET["socid"], $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1"; $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
/* /*
* Affichage onglets * Affichage onglets

View File

@ -79,15 +79,21 @@ print "</table></form>";
if ($conf->facture->enabled) { if ($conf->facture->enabled)
/* {
/*
* Factures brouillons * Factures brouillons
*/ */
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
if ( $db->query($sql) ) if ($socidp)
{ {
$sql .= " AND f.fk_soc = $socidp";
}
if ( $db->query($sql) )
{
$num = $db->num_rows(); $num = $db->num_rows();
$i = 0; $i = 0;
@ -109,12 +115,11 @@ if ( $db->query($sql) )
print "</table><br>"; print "</table><br>";
} }
} }
else else
{ {
print $sql; print $sql;
} }
} }
if ($conf->compta->enabled) { if ($conf->compta->enabled) {
@ -238,20 +243,25 @@ if ($user->comm > 0 && $conf->commercial->enabled )
} }
if ($conf->facture->enabled) { if ($conf->facture->enabled)
{
/* /*
* Factures impayées * Factures impayées
* *
*/ */
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am"; $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
$sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; $sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
$sql .= " GROUP BY f.facnumber"; if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY f.facnumber";
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
$num = $db->num_rows(); $num = $db->num_rows();
$i = 0; $i = 0;
@ -279,12 +289,11 @@ if ( $db->query($sql) )
print "</table><br>"; print "</table><br>";
} }
$db->free(); $db->free();
} }
else else
{ {
print $sql; print $sql;
} }
} }

View File

@ -22,10 +22,16 @@
require("./pre.inc.php"); require("./pre.inc.php");
llxHeader();
$mesg = ''; $mesg = '';
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader();
/* /*
* *
* *
@ -73,6 +79,10 @@ if ($_GET["id"])
$sql = "SELECT distinct(f.rowid), s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid"; $sql = "SELECT distinct(f.rowid), s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d WHERE f.fk_soc = s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d 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)
{
$sql .= " AND f.fk_soc = $socid";
}
$sql .= " ORDER BY $sortfield $sortorder "; $sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset); $sql .= $db->plimit( $limit ,$offset);