Gestion du paramtre $conf->compta->mode qui vaut 'DEPENSES-RECETTES' par dfaut, sinon 'CREANCES-DETTES'. Il dtermine le mode de calcul du CA.

This commit is contained in:
Laurent Destailleur 2004-02-14 02:04:29 +00:00
parent 8a29fa7a75
commit 054c6a5a81
7 changed files with 37 additions and 8 deletions

View File

@ -42,7 +42,10 @@ print_titre("Chiffre d'affaire par utilisateur (euros HT)");
*/
$sql = "SELECT sum(f.total) as ca FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_user_valid is not NULL AND f.fk_statut = 1";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
@ -64,7 +67,10 @@ if ($catotal == 0) { $catotal = 1; };
$sql = "SELECT u.name, u.firstname, sum(f.total) as ca";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_user_valid is not NULL and f.fk_statut = 1 AND f.fk_user_author = u.rowid";
$sql .= " WHERE f.fk_statut = 1 AND f.fk_user_author = u.rowid";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";

View File

@ -42,7 +42,10 @@ print_titre("Chiffre d'affaire par soci
*/
$sql = "SELECT sum(f.total) as ca FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_user_valid = 1 AND f.fk_statut = 1";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
@ -56,6 +59,9 @@ if ($result)
$catotal = $objp->ca;
}
}
else {
print $db->error() . "<br>" . $sql;
}
print "<br><b>Cumul : ".price($catotal)."</b>";
@ -64,7 +70,10 @@ if ($catotal == 0) { $catotal = 1; };
$sql = "SELECT s.nom, s.idp, sum(f.total) as ca";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1 and f.fk_user_valid = 1 AND f.fk_soc = s.idp";
$sql .= " WHERE f.fk_statut = 1 AND f.fk_soc = s.idp";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";

View File

@ -1,5 +1,6 @@
<?PHP
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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

View File

@ -41,7 +41,11 @@ print_titre("Chiffre d'affaire cumul
print '<table width="100%"><tr><td valign="top">';
$sql = "SELECT sum(f.total) as amount , date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE fk_user_valid is not NULL and f.paye = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
@ -53,7 +57,11 @@ pt($db, $sql,"Suivi cumul par mois");
print "</td><td valign=\"top\">";
$sql = "SELECT sum(f.total) as amount, year(f.datef) as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE fk_user_valid is not NULL and f.paye = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";

View File

@ -1,5 +1,6 @@
<?PHP
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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

View File

@ -39,8 +39,11 @@ if ($user->societe_id > 0)
print_titre("Chiffre d'affaire (".MAIN_MONNAIE." HT)");
$sql = "SELECT sum(f.total) as amount , date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = 1";
}
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";

View File

@ -1,5 +1,6 @@
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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