dolibarr/htdocs/compta/resultat/index.php3

216 lines
5.6 KiB
PHP
Raw Normal View History

2002-06-19 00:23:12 +02:00
<?PHP
2002-06-19 11:20:41 +02:00
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2002-06-19 00:23:12 +02:00
*
* 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.
*
2002-06-19 11:20:41 +02:00
* $Id$
* $Source$
*
2002-06-19 00:23:12 +02:00
*/
require("./pre.inc.php3");
require("../../tva.class.php3");
require("../../chargesociales.class.php3");
/*
*
*/
llxHeader();
2002-06-19 11:20:41 +02:00
?>
<style type="text/css">
td.border { border: 1px solid #000000}
</style>
2002-06-19 00:23:12 +02:00
2002-06-19 11:20:41 +02:00
<?PHP
2002-06-19 00:23:12 +02:00
$db = new Db();
2002-06-19 00:23:44 +02:00
print_titre("R<EFBFBD>sultat $year");
2002-06-19 00:23:12 +02:00
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print '<TR class="liste_titre">';
2002-06-19 11:20:41 +02:00
print '<td width="10%">&nbsp;</td><TD>El<45>ment</TD>';
print "<TD align=\"center\">Montant</TD><td align=\"right\">Solde</td>";
2002-06-19 00:23:12 +02:00
print "</TR>\n";
2002-06-19 11:05:49 +02:00
$sql = "SELECT s.nom,sum(f.amount) as amount";
2002-06-20 15:23:17 +02:00
$sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp";
2002-06-19 00:23:12 +02:00
if ($year > 0) {
$sql .= " AND date_format(f.datef, '%Y') = $year";
2002-06-20 15:23:17 +02:00
}
2002-06-19 11:05:49 +02:00
$sql .= " GROUP BY s.nom ASC";
2002-06-20 15:23:17 +02:00
2002-06-19 11:20:41 +02:00
print '<tr><td colspan="4">Factures</td></tr>';
2002-06-19 00:23:12 +02:00
$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;
2002-06-19 11:20:41 +02:00
print "<TR $bc[$var]><td>&nbsp</td>";
2002-06-20 21:25:15 +02:00
print "<td>Factures <a href=\"/compta/facture.php3?facid=$objp->facid\">$objp->facnumber</a> $objp->nom</TD>\n";
2002-06-19 00:23:12 +02:00
2002-06-19 11:20:41 +02:00
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";
2002-06-19 00:23:12 +02:00
$total = $total + $objp->amount;
print "<TD align=\"right\">".price($total)."</TD>\n";
print "</TR>\n";
$i++;
}
}
$db->free();
} else {
print $db->error();
}
2002-06-19 11:20:41 +02:00
print '<tr><td colspan="3" align="right">'.price($total).'</td></tr>';
2002-06-20 15:23:17 +02:00
/*
2002-06-20 21:25:15 +02:00
* Frais, factures fournisseurs.
*
2002-06-20 15:23:17 +02:00
*
*/
$sql = "SELECT s.nom,sum(f.amount) as amount";
$sql .= " FROM societe as s,llx_facture_fourn as f WHERE f.fk_soc = s.idp";
if ($year > 0) {
$sql .= " AND date_format(f.datef, '%Y') = $year";
}
$sql .= " GROUP BY s.nom ASC";
print '<tr><td colspan="4">Frais</td></tr>';
2002-06-20 21:25:15 +02:00
$subtotal = 0;
2002-06-20 15:23:17 +02:00
$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 "<TR $bc[$var]><td>&nbsp</td>";
2002-07-03 14:46:00 +02:00
print "<td>Factures <a href=\"/fourn/facture/\">$objp->nom</a></TD>\n";
2002-06-20 15:23:17 +02:00
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";
$total = $total - $objp->amount;
2002-06-20 21:25:15 +02:00
$subtotal = $subtotal + $objp->amount;
2002-06-20 15:23:17 +02:00
print "<TD align=\"right\">".price($total)."</TD>\n";
print "</TR>\n";
$i++;
}
}
$db->free();
} else {
print $db->error();
}
2002-06-20 21:25:15 +02:00
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
2002-06-20 15:23:17 +02:00
2002-06-19 00:23:12 +02:00
/*
* Charges sociales
*
*/
2002-06-19 11:20:41 +02:00
$subtotal = 0;
print '<tr><td colspan="4">Prestations d<>ductibles</td></tr>';
2002-06-19 00:23:12 +02:00
2002-06-19 11:05:49 +02:00
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
2002-06-19 00:23:12 +02:00
$sql .= " FROM c_chargesociales as c, llx_chargesociales as s";
2002-06-19 11:20:41 +02:00
$sql .= " WHERE s.fk_type = c.id AND c.deductible=1";
2002-06-19 00:23:12 +02:00
if ($year > 0) {
$sql .= " AND date_format(s.periode, '%Y') = $year";
}
2002-06-19 11:05:49 +02:00
$sql .= " GROUP BY c.libelle DESC";
2002-06-19 00:23:12 +02:00
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object( $i);
2002-06-19 11:20:41 +02:00
$total = $total - $obj->amount;
$subtotal = $subtotal + $obj->amount;
2002-06-19 00:23:12 +02:00
$var = !$var;
2002-06-19 11:20:41 +02:00
print "<tr $bc[$var]><td>&nbsp</td>";
2002-06-19 11:05:49 +02:00
print '<td>'.$obj->nom.'</td>';
2002-06-19 11:20:41 +02:00
print '<td align="right">'.price($obj->amount).'</td>';
2002-06-19 00:23:12 +02:00
print "<TD align=\"right\">".price($total)."</TD>\n";
2002-06-19 11:20:41 +02:00
print '</tr>';
$i++;
}
} else {
print $db->error();
}
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
print '<tr><td align="right" colspan="2">R<>sultat</td><td class="border" align="right">'.price($total).'</td></tr>';
/*
* Charges sociales non d<EFBFBD>ductibles
*
*/
$subtotal = 0;
print '<tr><td colspan="4">Prestations NON d<>ductibles</td></tr>';
$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";
if ($year > 0) {
$sql .= " AND date_format(s.periode, '%Y') = $year";
}
$sql .= " GROUP BY c.libelle DESC";
2002-06-19 00:23:12 +02:00
2002-06-19 11:20:41 +02:00
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 "<tr $bc[$var]><td>&nbsp</td>";
print '<td>'.$obj->nom.'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
print "<TD align=\"right\">".price($total)."</TD>\n";
2002-06-19 00:23:12 +02:00
print '</tr>';
$i++;
}
} else {
print $db->error();
}
2002-06-19 11:20:41 +02:00
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
2002-06-19 00:23:12 +02:00
2002-06-19 11:20:41 +02:00
print '<tr><td align="right" colspan="2">R<>sultat</td><td class="border" align="right">'.price($total).'</td></tr>';
2002-06-19 00:23:12 +02:00
print "</TABLE>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>