Fix: pgsql compatibility

This commit is contained in:
Laurent Destailleur 2011-03-09 10:09:07 +00:00
parent 8b8803a7b8
commit 95361b8923

View File

@ -80,6 +80,10 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely) $sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
if ($y && $m) if ($y && $m)
{ {
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
@ -116,6 +120,10 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (2)"; // Paid (partially or completely) $sql.= " f.fk_statut in (2)"; // Paid (partially or completely)
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
if ($y && $m) if ($y && $m)
{ {
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
@ -303,6 +311,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND (d.product_type = 0"; // Limit to products
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
$sql.= " ORDER BY d.rowid, d.".$fk_facture; $sql.= " ORDER BY d.rowid, d.".$fk_facture;
//print $sql;
} }
} }