Patch Yannick

This commit is contained in:
Laurent Destailleur 2006-10-14 17:06:50 +00:00
parent cc2217a8a4
commit fcc2a026a2

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,53 +18,54 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
function get_ca_propal ($db, $year, $socid) 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 "; $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) if ($socid)
{ {
$sql .= " AND f.fk_soc = $socid"; $sql .= " AND f.fk_soc = $socid";
} }
$result = $db->query($sql);
if ($result) $result = $db->query($sql);
{
return $db->result (0, 0); if ($result)
} {
else $res = $db->fetch_object($result);
{ return $res->sum;
return 0; }
} else
{
return 0;
}
} }
function get_ca ($db, $year, $socid) 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) $sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f";
{ $sql .= " WHERE f.fk_statut = 1";
return $db->result ( 0, 0); if ($conf->compta->mode != 'CREANCES-DETTES') {
} $sql .= " AND f.paye = 1";
else }
{ $sql .= " AND date_format(f.datef , '%Y') = $year ";
return 0; 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;
}
} }