From df8da8678b4da3484583fbcd2dcf8d9fc8f058e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jul 2011 10:30:00 +0000 Subject: [PATCH] Fix: pgql compatibility --- htdocs/adherents/class/adherentstats.class.php | 8 ++++---- htdocs/comm/propal.php | 10 +++++----- htdocs/comm/propal/class/propalestats.class.php | 8 ++++---- htdocs/commande/class/commandestats.class.php | 8 ++++---- htdocs/commande/liste.php | 12 ++++++------ .../deplacement/class/deplacementstats.class.php | 6 +++--- .../compta/facture/class/facturestats.class.php | 6 +++--- htdocs/compta/propal.php | 10 +++++----- htdocs/compta/sociales/index.php | 8 ++++---- htdocs/compta/stats/comp.php | 15 ++++++++------- htdocs/compta/tva/quadri.php | 16 ++++++++-------- .../expedition/class/expeditionstats.class.php | 4 ++-- htdocs/lib/accountancy.lib.php | 15 ++++++++------- 13 files changed, 64 insertions(+), 62 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 81d77d1f2c9..b47532e4a8c 100755 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -22,7 +22,7 @@ * \file htdocs/adherents/class/adherentstats.class.php * \ingroup member * \brief Fichier de la classe de gestion des stats des adhérents - * \version $Id$ + * \version $Id: adherentstats.class.php,v 1.2 2011/07/04 10:30:01 eldy Exp $ */ include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php"; @@ -90,7 +90,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; $sql.= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year; + $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -126,7 +126,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; $sql.= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year; + $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -144,7 +144,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")"; $sql.= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year; + $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 81169c18ab8..fd08c7bc5f5 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -27,7 +27,7 @@ * \file htdocs/comm/propal.php * \ingroup propale * \brief Page of commercial proposals card and list - * \version $Id: propal.php,v 1.607 2011/07/02 16:48:32 eldy Exp $ + * \version $Id: propal.php,v 1.608 2011/07/04 10:30:02 eldy Exp $ */ require("../main.inc.php"); @@ -1805,13 +1805,13 @@ else if ($month > 0) { if ($year > 0) - $sql.= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; + $sql.= " AND date_format(p.datep, '%Y-%m') = '".$year."-".$month."'"; else - $sql.= " AND date_format(p.datep, '%m') = '$month'"; + $sql.= " AND date_format(p.datep, '%m') = '".$month."'"; } if ($year > 0) { - $sql.= " AND date_format(p.datep, '%Y') = $year"; + $sql.= " AND date_format(p.datep, '%Y') = '".$year."'"; } if (dol_strlen($_POST['sf_ref']) > 0) { @@ -1975,6 +1975,6 @@ else } $db->close(); -llxFooter('$Date: 2011/07/02 16:48:32 $ - $Revision: 1.607 $'); +llxFooter('$Date: 2011/07/04 10:30:02 $ - $Revision: 1.608 $'); ?> diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index ac120ef6d4d..d880478352e 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -22,7 +22,7 @@ * \file htdocs/comm/propal/class/propalestats.class.php * \ingroup propales * \brief Fichier de la classe de gestion des stats des propales - * \version $Id$ + * \version $Id: propalestats.class.php,v 1.5 2011/07/04 10:30:03 eldy Exp $ */ include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php"; @@ -91,7 +91,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, count(*)"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = ".$year; + $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -127,7 +127,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = ".$year; + $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -145,7 +145,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = ".$year; + $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 95ab36d59ff..9523d879cd9 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -22,7 +22,7 @@ * \file htdocs/commande/class/commandestats.class.php * \ingroup commandes * \brief Fichier de la classe de gestion des stats des commandes - * \version $Id$ + * \version $Id: commandestats.class.php,v 1.5 2011/07/04 10:30:01 eldy Exp $ */ include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php"; include_once DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php"; @@ -102,7 +102,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, count(*) nb"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_valid,'%Y') = ".$year; + $sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -141,7 +141,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, sum(c.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_valid,'%Y') = ".$year; + $sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -161,7 +161,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, avg(c.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_valid,'%Y') = ".$year; + $sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 4e1c0f03c1e..871fe80c498 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -23,7 +23,7 @@ * \file htdocs/commande/liste.php * \ingroup commande * \brief Page to list orders - * \version $Id$ + * \version $Id: liste.php,v 1.77 2011/07/04 10:30:02 eldy Exp $ */ @@ -115,19 +115,19 @@ if ($viewstatut <> '') } if ($_GET['ordermonth'] > 0) { - $sql.= " AND date_format(c.date_valid, '%Y-%m') = '$orderyear-$ordermonth'"; + $sql.= " AND date_format(c.date_valid, '%Y-%m') = '".$orderyear."-".$ordermonth."'"; } if ($_GET['orderyear'] > 0) { - $sql.= " AND date_format(c.date_valid, '%Y') = $orderyear"; + $sql.= " AND date_format(c.date_valid, '%Y') = '".$orderyear."'"; } if ($_GET['deliverymonth'] > 0) { - $sql.= " AND date_format(c.date_livraison, '%Y-%m') = '$deliveryyear-$deliverymonth'"; + $sql.= " AND date_format(c.date_livraison, '%Y-%m') = '".$deliveryyear."-".$deliverymonth."'"; } if ($_GET['deliveryyear'] > 0) { - $sql.= " AND date_format(c.date_livraison, '%Y') = $deliveryyear"; + $sql.= " AND date_format(c.date_livraison, '%Y') = '".$deliveryyear."'"; } if (!empty($snom)) { @@ -278,5 +278,5 @@ else $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/04 10:30:02 $ - $Revision: 1.77 $'); ?> diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index eb317b6d5f5..375d2901b1f 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -22,7 +22,7 @@ * \file htdocs/compta/deplacement/class/deplacementstats.class.php * \ingroup factures * \brief Fichier de la classe de gestion des stats des deplacement et notes de frais - * \version $Id$ + * \version $Id: deplacementstats.class.php,v 1.5 2011/07/04 10:30:02 eldy Exp $ */ include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php"; include_once DOL_DOCUMENT_ROOT . "/compta/deplacement/class/deplacement.class.php"; @@ -117,7 +117,7 @@ class DeplacementStats extends Stats { $sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(dated,'%Y') = ".$year; + $sql.= " WHERE date_format(dated,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -136,7 +136,7 @@ class DeplacementStats extends Stats { $sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(dated,'%Y') = ".$year; + $sql.= " WHERE date_format(dated,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 2953c14ba19..9ae7ef1aad9 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -22,7 +22,7 @@ * \file htdocs/compta/facture/class/facturestats.class.php * \ingroup factures * \brief Fichier de la classe de gestion des stats des factures - * \version $Id$ + * \version $Id: facturestats.class.php,v 1.6 2011/07/04 10:30:01 eldy Exp $ */ include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php"; include_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php"; @@ -78,7 +78,7 @@ class FactureStats extends Stats $this->where = " fk_statut > 0"; $this->where.= " AND entity = ".$conf->entity; - if ($mode == 'customer') $this->where.=" AND (fk_statut != 3 OR close_code != 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) + if ($mode == 'customer') $this->where.=" AND (fk_statut <> 3 OR close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) { $this->where.=" AND fk_soc = ".$this->socid; @@ -132,7 +132,7 @@ class FactureStats extends Stats { $sql = "SELECT date_format(datef,'%m') as dm, SUM(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datef,'%Y') = ".$year; + $sql.= " WHERE date_format(datef,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index bbe0895a61a..d4db8280805 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -25,7 +25,7 @@ * \file htdocs/compta/propal.php * \ingroup propale * \brief Page liste des propales (vision compta) - * \version $Id$ + * \version $Id: propal.php,v 1.193 2011/07/04 10:30:00 eldy Exp $ */ require('../main.inc.php'); @@ -561,11 +561,11 @@ else if ($month > 0) { if ($year > 0) - $sql.= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; + $sql.= " AND date_format(p.datep, '%Y-%m') = '".$year."-".$month."'"; else - $sql.= " AND date_format(p.datep, '%m') = '$month'"; + $sql.= " AND date_format(p.datep, '%m') = '".$month."'"; } - if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = $year"; + if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = '".$year."'"; if (!empty($_GET['search_ref'])) { $sql.= " AND p.ref LIKE '%".$db->escape($_GET['search_ref'])."%'"; @@ -702,6 +702,6 @@ else $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/04 10:30:00 $ - $Revision: 1.193 $'); ?> diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index daafa781843..2aa820b029c 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -22,7 +22,7 @@ * \file htdocs/compta/sociales/index.php * \ingroup tax * \brief Page to list all social contributions - * \version $Id$ + * \version $Id: index.php,v 1.65 2011/07/04 10:30:01 eldy Exp $ */ require('../../main.inc.php'); @@ -86,8 +86,8 @@ if ($year > 0) $sql .= " AND ("; // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (s.periode is not null and date_format(s.periode, '%Y') = ".$year.") "; - $sql .= "or (s.periode is null and date_format(s.date_ech, '%Y') = ".$year.")"; + $sql .= " (s.periode is not null and date_format(s.periode, '%Y') = '".$year."') "; + $sql .= "or (s.periode is null and date_format(s.date_ech, '%Y') = '".$year."')"; $sql .= ")"; } if ($filtre) { @@ -229,5 +229,5 @@ else $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/04 10:30:01 $ - $Revision: 1.65 $'); ?> diff --git a/htdocs/compta/stats/comp.php b/htdocs/compta/stats/comp.php index 5bee40758d8..e431ec86b78 100644 --- a/htdocs/compta/stats/comp.php +++ b/htdocs/compta/stats/comp.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/stats/comp.php * \ingroup commercial - * \version $Id: comp.php,v 1.43 2011/06/29 11:22:36 eldy Exp $ + * \version $Id: comp.php,v 1.44 2011/07/04 10:30:01 eldy Exp $ * TODO Remove or add page in menus */ @@ -47,8 +47,9 @@ function propals ($db, $year, $month) $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.fk_statut in (1,2,4)"; - $sql.= " AND date_format(p.datep, '%Y') = ".$year; - $sql.= " AND round(date_format(p.datep, '%m')) = ".$month; + // TODO Use between instead of date_format + $sql.= " AND date_format(p.datep, '%Y') = '".$year."'"; + $sql.= " AND round(date_format(p.datep, '%m')) = '".$month."'"; $sql.= " ORDER BY p.fk_statut"; $result = $db->query($sql); @@ -121,7 +122,7 @@ function factures ($db, $year, $month, $paye) $sql.= " AND f.entity = ".$conf->entity; if ($conf->compta->mode != 'CREANCES-DETTES') $sql.= " AND f.paye = ".$paye; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND date_format(f.datef, '%Y') = ".$year; + $sql.= " AND date_format(f.datef, '%Y') = '".$year."'"; $sql.= " AND round(date_format(f.datef, '%m')) = ".$month; $sql.= " ORDER BY f.datef DESC "; @@ -271,7 +272,7 @@ function ppt ($db, $year, $socid) $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= " WHERE p.fk_statut in (1,2,4)"; $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND date_format(p.datep,'%Y') = ".$year; + $sql.= " AND date_format(p.datep,'%Y') = '".$year."'"; if ($socid) $sql.= " AND p.fk_soc = ".$socid; $sql.= " GROUP BY dm"; @@ -284,7 +285,7 @@ function ppt ($db, $year, $socid) $sql.= " WHERE f.fk_statut in (1,2)"; $sql.= " AND f.entity = ".$conf->entity; if ($conf->compta->mode != 'CREANCES-DETTES') $sql.= " AND f.paye = 1"; - $sql.= " AND date_format(f.datef,'%Y') = ".$year; + $sql.= " AND date_format(f.datef,'%Y') = '".$year."'"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY dm"; @@ -350,5 +351,5 @@ if ($details == 1) $db->close(); -llxFooter('$Date: 2011/06/29 11:22:36 $ - $Revision: 1.43 $'); +llxFooter('$Date: 2011/07/04 10:30:01 $ - $Revision: 1.44 $'); ?> diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php index 8ada959f602..f85c447f383 100644 --- a/htdocs/compta/tva/quadri.php +++ b/htdocs/compta/tva/quadri.php @@ -24,7 +24,7 @@ \file htdocs/compta/tva/quadri.php \ingroup tax \brief Trimestrial page - \version $Id: quadri.php,v 1.14 2011/07/04 09:01:38 eldy Exp $ + \version $Id: quadri.php,v 1.15 2011/07/04 10:30:00 eldy Exp $ \todo Deal with recurrent invoices as well */ @@ -70,9 +70,9 @@ function tva_coll($db,$y,$q) $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND f.fk_statut in (1,2)"; $sql.= " AND f.rowid = d.fk_facture "; - $sql.= " AND date_format(f.datef,'%Y') = ".$y; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3); - $sql.= " AND date_format(f.datef,'%m') <= ".($q*3).")"; + $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; + $sql.= " AND (round(date_format(f.datef,'%m') > ".(($q-1)*3); + $sql.= " AND round(date_format(f.datef,'%m')) <= ".($q*3).")"; $sql.= " ORDER BY rate, facid"; } @@ -136,9 +136,9 @@ function tva_paye($db, $y,$q) $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND f.fk_statut = 1 "; $sql.= " AND f.rowid = d.fk_facture_fourn "; - $sql.= " AND date_format(f.datef,'%Y') = ".$y; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3); - $sql.= " AND date_format(f.datef,'%m') <= ".($q*3).")"; + $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; + $sql.= " AND (round(date_format(f.datef,'%m')) > ".(($q-1)*3); + $sql.= " AND round(date_format(f.datef,'%m')) <= ".($q*3).")"; $sql.= " ORDER BY rate, facid "; } else @@ -315,5 +315,5 @@ echo ''; $db->close(); -llxFooter('$Date: 2011/07/04 09:01:38 $ - $Revision: 1.14 $'); +llxFooter('$Date: 2011/07/04 10:30:00 $ - $Revision: 1.15 $'); ?> diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index 13e7de1b589..d7bf1e9dd7a 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -21,7 +21,7 @@ * \file htdocs/expedition/class/expeditionstats.class.php * \ingroup expedition * \brief Fichier des classes expedition - * \version $Id$ + * \version $Id: expeditionstats.class.php,v 1.4 2011/07/04 10:30:01 eldy Exp $ */ /** @@ -78,7 +78,7 @@ class ExpeditionStats $result = array(); $sql = "SELECT count(*), date_format(date_expedition,'%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; - $sql.= " WHERE date_format(date_expedition,'%Y') = ".$year; + $sql.= " WHERE date_format(date_expedition,'%Y') = '".$year."'"; $sql.= " AND fk_statut > 0"; $sql.= " AND entity = ".$conf->entity; $sql.= " GROUP BY dm DESC"; diff --git a/htdocs/lib/accountancy.lib.php b/htdocs/lib/accountancy.lib.php index 57072ea1bad..6ef49c8af6a 100644 --- a/htdocs/lib/accountancy.lib.php +++ b/htdocs/lib/accountancy.lib.php @@ -20,21 +20,23 @@ /** * \file htdocs/lib/accountancy.lib.php * \brief Library of accountancy functions - * \version $Id$ + * \version $Id: accountancy.lib.php,v 1.2 2011/07/04 10:30:01 eldy Exp $ */ - +/** + * @param $db + * @param $year + * @param $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) { $sql .= " AND f.fk_soc = $socid"; } $result = $db->query($sql); - if ($result) { $res = $db->fetch_object($result); @@ -56,14 +58,13 @@ function get_ca ($db, $year, $socid) if ($conf->compta->mode != 'CREANCES-DETTES') { $sql .= " AND f.paye = 1"; } - $sql .= " AND date_format(f.datef , '%Y') = $year "; + $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);