*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
require("../../tva.class.php");
require("../../chargesociales.class.php");
/*
*
*/
llxHeader();
$user->getrights('compta');
if (!$user->admin && !$user->rights->compta->resultat)
accessforbidden();
?>
";
print '
';
print '| | Elément | ';
print "Montant | ";
print "
\n";
$sql = "SELECT s.nom,sum(f.amount) as amount";
$sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp";
$sql .= " GROUP BY s.nom ASC";
print '| Factures |
';
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0;
if ($num > 0) {
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "|   | ";
print "Factures facid\">$objp->facnumber $objp->nom | \n";
print "".price($objp->amount)." | \n";
$total = $total + $objp->amount;
print "
\n";
$i++;
}
}
$db->free();
} else {
print $db->error();
}
print '| '.price($total).' |
';
/*
* Frais, factures fournisseurs.
*
*
*/
$sql = "SELECT s.nom,s.idp,sum(f.total_ht) as amount";
$sql .= " FROM llx_societe as s,llx_facture_fourn as f WHERE f.fk_soc = s.idp";
$sql .= " GROUP BY s.nom ASC, s.idp";
print '| Frais |
';
$subtotal = 0;
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0;
if ($num > 0) {
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "|   | ";
print "Factures idp."\">$objp->nom | \n";
print "".price($objp->amount)." | \n";
$total = $total - $objp->amount;
$subtotal = $subtotal + $objp->amount;
print "
\n";
$i++;
}
}
$db->free();
} else {
print $db->error();
}
print '| '.price($subtotal).' |
';
/*
* Charges sociales
*
*/
$subtotal = 0;
print '| Prestations déductibles |
';
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
$sql .= " FROM c_chargesociales as c, llx_chargesociales as s";
$sql .= " WHERE s.fk_type = c.id AND c.deductible=1";
$sql .= " GROUP BY c.libelle DESC";
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$total = $total - $obj->amount;
$subtotal = $subtotal + $obj->amount;
$var = !$var;
print "|   | ";
print ''.$obj->nom.' | ';
print ''.price($obj->amount).' | ';
print '
';
$i++;
}
} else {
print $db->error();
}
print '| '.price($subtotal).' |
';
print '| Résultat | '.price($total).' |
';
/*
* Charges sociales non déductibles
*
*/
$subtotal = 0;
print '| Prestations NON déductibles |
';
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
$sql .= " FROM c_chargesociales as c, llx_chargesociales as s";
$sql .= " WHERE s.fk_type = c.id AND c.deductible=0";
$sql .= " GROUP BY c.libelle DESC";
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$total = $total - $obj->amount;
$subtotal = $subtotal + $obj->amount;
$var = !$var;
print "|   | ";
print ''.$obj->nom.' | ';
print ''.price($obj->amount).' | ';
print '
';
$i++;
}
} else {
print $db->error();
}
print '| '.price($subtotal).' |
';
print '| Résultat | '.price($total).' |
';
print "";
$db->close();
llxFooter("Dernière modification $Date$ révision $Revision$");
?>