From fcc2a026a23cd5a8cc73b13a8dc7d0cdeeb8d400 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Oct 2006 17:06:50 +0000 Subject: [PATCH] Patch Yannick --- htdocs/compta/stats/lib.inc.php | 79 +++++++++++++++++---------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/stats/lib.inc.php b/htdocs/compta/stats/lib.inc.php index 1f2830bfec0..8fd3b1f8f4e 100644 --- a/htdocs/compta/stats/lib.inc.php +++ b/htdocs/compta/stats/lib.inc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2006 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 @@ -18,53 +18,54 @@ * * $Id$ * $Source$ - * */ function get_ca_propal ($db, $year, $socid) { - $sql = "SELECT sum(f.price - f.remise) as sum FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in (1,2,4) AND date_format(f.datep, '%Y') = $year "; - if ($socid) - { - $sql .= " AND f.fk_soc = $socid"; - } - - $result = $db->query($sql); + $sql = "SELECT sum(f.price - f.remise) as sum FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in (1,2,4) AND date_format(f.datep, '%Y') = $year "; + if ($socid) + { + $sql .= " AND f.fk_soc = $socid"; + } - if ($result) - { - return $db->result (0, 0); - } - else - { - return 0; - } + $result = $db->query($sql); + + if ($result) + { + $res = $db->fetch_object($result); + return $res->sum; + } + else + { + return 0; + } } function get_ca ($db, $year, $socid) { - - $sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.fk_statut = 1"; - if ($conf->compta->mode != 'CREANCES-DETTES') { - $sql .= " AND f.paye = 1"; - } - $sql .= " AND date_format(f.datef , '%Y') = $year "; - if ($socid) - { - $sql .= " AND f.fk_soc = $socid"; - } - - $result = $db->query($sql); - if ($result) - { - return $db->result ( 0, 0); - } - else - { - return 0; - } + $sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.fk_statut = 1"; + if ($conf->compta->mode != 'CREANCES-DETTES') { + $sql .= " AND f.paye = 1"; + } + $sql .= " AND date_format(f.datef , '%Y') = $year "; + if ($socid) + { + $sql .= " AND f.fk_soc = $socid"; + } + + $result = $db->query($sql); + + if ($result) + { + $res = $db->fetch_object($result); + return $res->sum; + } + else + { + return 0; + } }