From 81a679921860f0fd6af2084c86017ee1430d61bf Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 29 Jul 2004 13:32:29 +0000 Subject: [PATCH] =?UTF-8?q?Modif=20s=E9curit=E9=20acc=E9s=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/fiche.php | 11 +-- htdocs/compta/index.php | 163 ++++++++++++++++--------------- htdocs/product/stats/facture.php | 14 ++- 3 files changed, 103 insertions(+), 85 deletions(-) diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 322eb9f228f..f8c405166c7 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -30,10 +30,11 @@ require("../facture.class.php"); /* * Sécurité accés client */ +$socid = $_GET["socid"]; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } $user->getrights('facture'); @@ -130,17 +131,15 @@ if ($mode == 'search') } - - /* * * Mode fiche * */ -if ($_GET["socid"] > 0) +if ($socid > 0) { $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 diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index fa000adbc92..8ad50feae70 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -79,42 +79,47 @@ print ""; -if ($conf->facture->enabled) { -/* - * 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"; - -if ( $db->query($sql) ) +if ($conf->facture->enabled) { - $num = $db->num_rows(); - $i = 0; - - if ($num) + /* + * 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"; + + if ($socidp) { - print ''; - print ''; - print ''; - $var = True; - while ($i < $num) - { - $obj = $db->fetch_object( $i); - $var=!$var; - print ''; - print ''; - $i++; - } - - print "
Factures brouillons
'.img_file().' '; - print ''.$obj->facnumber.''.$obj->nom.'

"; + $sql .= " AND f.fk_soc = $socidp"; } -} -else -{ - print $sql; -} - + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + $i = 0; + + if ($num) + { + print ''; + print ''; + print ''; + $var = True; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var=!$var; + print ''; + print ''; + $i++; + } + + print "
Factures brouillons
'.img_file().' '; + print ''.$obj->facnumber.''.$obj->nom.'

"; + } + } + else + { + print $sql; + } } if ($conf->compta->enabled) { @@ -238,53 +243,57 @@ if ($user->comm > 0 && $conf->commercial->enabled ) } -if ($conf->facture->enabled) { - -/* - * Factures impayées - * - */ - -$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 .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; -$sql .= " GROUP BY f.facnumber"; - -if ( $db->query($sql) ) +if ($conf->facture->enabled) { - $num = $db->num_rows(); - $i = 0; - - if ($num) + + /* + * Factures impayées + * + */ + + $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 .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; + if ($socidp) { - print ''; - print ''; - $var = True; - $total = $totalam = 0; - while ($i < $num) - { - $obj = $db->fetch_object( $i); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - $total += $obj->total_ttc; - $totalam += $obj->am; - $i++; - } - $var=!$var; - print ''; - print "
Factures clients impayéesMontant TTCReçu
'.img_file().''; - print ' '.$obj->facnumber.''.$obj->nom.''.price($obj->total_ttc).''.price($obj->am).'
Reste à encaisser : '.price($total-$totalam).''.price($total).''.price($totalam).'

"; + $sql .= " AND f.fk_soc = $socidp"; } - $db->free(); -} -else -{ - print $sql; -} - + $sql .= " GROUP BY f.facnumber"; + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + $i = 0; + + if ($num) + { + print ''; + print ''; + $var = True; + $total = $totalam = 0; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var=!$var; + print ''; + print ''; + print ''; + print ''; + $total += $obj->total_ttc; + $totalam += $obj->am; + $i++; + } + $var=!$var; + print ''; + print "
Factures clients impayéesMontant TTCReçu
'.img_file().''; + print ' '.$obj->facnumber.''.$obj->nom.''.price($obj->total_ttc).''.price($obj->am).'
Reste à encaisser : '.price($total-$totalam).''.price($total).''.price($totalam).'

"; + } + $db->free(); + } + else + { + print $sql; + } } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index df371d7448b..3a98ee07050 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -22,10 +22,16 @@ require("./pre.inc.php"); -llxHeader(); - $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 .= " 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; + if ($socid) + { + $sql .= " AND f.fk_soc = $socid"; + } $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit( $limit ,$offset);