From af6db0b09b159eaba479aecabec14daa83907152 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 May 2004 15:58:38 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Le=20r=E9sum=E9=20des=20charges=20affich?= =?UTF-8?q?e=20le=20nb=20d'appel=20de=20charges,=20le=20montant=20pay=E9?= =?UTF-8?q?=20en=20plus=20du=20total.=20New:=20Le=20lien=20sur=20un=20type?= =?UTF-8?q?=20de=20charge=20sociale=20et=20clicable=20et=20am=E8ne=20sur?= =?UTF-8?q?=20la=20page=20des=20charges=20sociales=20avec=20filtre=20sur?= =?UTF-8?q?=20ce=20type.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/charges/index.php | 65 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 3e965be97a6..0950ad023aa 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -25,37 +25,35 @@ require("./pre.inc.php"); llxHeader(); $user->getrights('compta'); - if (!$user->admin && !$user->rights->compta->charges) accessforbidden(); -function valeur($sql) -{ - global $db; - if ( $db->query($sql) ) - { - if ( $db->num_rows() ) - { - $valeur = $db->result(0,0); - } - $db->free(); - } - return $valeur; -} + +$year=$_GET["year"]; +$filtre=$_GET["filtre"]; + + +print_titre("Charges - Résumé".($year > 0?" $year":"")); + +print "
"; +print ''; +print ""; +print ""; +print ""; +print ""; +print ""; +print "\n"; + /* - * + * Charges sociales */ - -print_titre("Charges"); - -print '
GroupeNbMontant TTCMontant Payé
'; -print ""; -print ""; -print "\n"; - -$sql = "SELECT c.libelle as nom, sum(s.amount) as total"; +$sql = "SELECT c.libelle as lib, s.fk_type as type, count(s.rowid) as nb, sum(s.amount) as total, sum(IF(paye=1,s.amount,0)) as totalpaye"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s"; -$sql .= " WHERE s.fk_type = c.id AND s.paye = 1"; +$sql .= " WHERE s.fk_type = c.id"; +if ($year > 0) +{ + $sql .= " AND date_format(s.date_ech, '%Y') = $year"; +} $sql .= " GROUP BY lower(c.libelle) ASC"; if ( $db->query($sql) ) @@ -67,18 +65,26 @@ if ( $db->query($sql) ) $obj = $db->fetch_object( $i); $var = !$var; print ""; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; $i++; } } else { print ""; } + /* * Factures fournisseurs */ -$sql = "SELECT sum(f.amount) as total"; +$sql = "SELECT count(f.rowid) as nb, sum(total_ttc) as total, sum(IF(paye=1,total_ttc,0)) as totalpaye"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; +if ($year > 0) +{ + $sql .= " WHERE date_format(f.datef, '%Y') = $year"; +} if ( $db->query($sql) ) { $num = $db->num_rows(); @@ -88,7 +94,10 @@ if ( $db->query($sql) ) { $obj = $db->fetch_object( $i); $var = !$var; print ""; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; $i++; }
Factures
'.$obj->nom.''.price($obj->total).''.$obj->lib.''.$obj->nb.''.price($obj->total).''.price($obj->totalpaye).'
".$db->error()."
Factures founisseurs'.price($obj->total).'Factures founisseurs'.$obj->nb.''.price($obj->total).''.price($obj->totalpaye).'