diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 65e94d2470f..712cb22e8b3 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -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"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index f5037da50be..5184c6c7fba 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -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() . "
" . $sql; +} print "
Cumul : ".price($catotal).""; @@ -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"; diff --git a/htdocs/compta/stats/comp.php b/htdocs/compta/stats/comp.php index f627e483bbe..055ae41296d 100644 --- a/htdocs/compta/stats/comp.php +++ b/htdocs/compta/stats/comp.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * 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 diff --git a/htdocs/compta/stats/cumul.php b/htdocs/compta/stats/cumul.php index 07004cf5776..54586a965f9 100644 --- a/htdocs/compta/stats/cumul.php +++ b/htdocs/compta/stats/cumul.php @@ -41,7 +41,11 @@ print_titre("Chiffre d'affaire cumul print '
'; $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 ""; $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"; diff --git a/htdocs/compta/stats/exercices.php b/htdocs/compta/stats/exercices.php index d4529550940..781d5134712 100644 --- a/htdocs/compta/stats/exercices.php +++ b/htdocs/compta/stats/exercices.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * 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 diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 908db13f70e..c59ad29ff79 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -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"; diff --git a/htdocs/compta/stats/lib.inc.php b/htdocs/compta/stats/lib.inc.php index 407695213af..b6102b5d64e 100644 --- a/htdocs/compta/stats/lib.inc.php +++ b/htdocs/compta/stats/lib.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * 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