From d7ffb431a77fdced897672fa453380e0eef744b0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Apr 2010 08:22:29 +0000 Subject: [PATCH] Fix: pgsql compatibility --- htdocs/compta/bank/search.php | 9 +++++---- htdocs/compta/facture.php | 12 +++++------- htdocs/compta/paiement.php | 14 +++++++------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 294c609e95b..e7b60fee8da 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copytight (C) 2005-2009 Regis Houssin + * Copytight (C) 2005-2010 Regis Houssin * * 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 @@ -76,10 +76,11 @@ $sql = "SELECT b.rowid, b.dateo as do, b.amount, b.label, b.rappro, b.num_releve $sql.= " b.fk_account, b.fk_type,"; $sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " bu.label as labelurl, bu.url_id"; -$sql.= " FROM ("; +$sql.= " FROM "; if (! empty($_REQUEST["bid"])) $sql.= MAIN_DB_PREFIX."bank_class as l, "; -$sql.= MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu on (bu.fk_bank = b.rowid AND type = 'company')"; +$sql.= MAIN_DB_PREFIX."bank_account as ba, "; +$sql.= MAIN_DB_PREFIX."bank as b"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; if (! empty($_REQUEST["bid"])) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 29b2078ac37..4f902fdba1f 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3701,11 +3701,9 @@ else $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; $sql.= ' s.nom, s.rowid as socid'; - if (! $sall) $sql.= ' ,sum(pf.amount) as am'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; - if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid'; $sql.= ' WHERE f.fk_soc = s.rowid'; $sql.= " AND f.entity = ".$conf->entity; @@ -3755,7 +3753,6 @@ else { $sql.= ' AND (s.nom LIKE \'%'.addslashes($sall).'%\' OR f.facnumber LIKE \'%'.addslashes($sall).'%\' OR f.note LIKE \'%'.addslashes($sall).'%\' OR fd.description LIKE \'%'.addslashes($sall).'%\')'; } - $sql.= ' GROUP BY f.rowid'; $sql.= ' ORDER BY '; $listfield=explode(',',$sortfield); @@ -3843,6 +3840,7 @@ else $facturestatic->id=$objp->facid; $facturestatic->ref=$objp->facnumber; $facturestatic->type=$objp->type; + $paiement = $facturestatic->getSommePaiement(); print ''; @@ -3882,7 +3880,7 @@ else // Date limit print ''; - print ''; + print ''; // Affiche statut de la facture print '"; //print ""; print "\n"; $total+=$objp->total; $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + $totalrecu+=$paiement; $i++; } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 400591806d2..9d5e9d89ef7 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * * This program is free software; you can redistribute it and/or modify @@ -327,10 +328,8 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P * List of unpaid invoices */ $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.type, '; - $sql.= $db->pdate('f.datef').' as df, '; - $sql.= ' sum(pf.amount) as am'; + $sql.= $db->pdate('f.datef').' as df'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; $sql.= ' WHERE f.fk_soc = '.$facture->socid; $sql.= ' AND f.paye = 0'; $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled @@ -342,7 +341,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P { $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes } - $sql .= ' GROUP BY f.facnumber'; + $resql = $db->query($sql); if ($resql) { @@ -395,13 +394,14 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P print ''; // Recu - print ''; // Reste a payer - print ''; + print ''; // Montant print '
'.dol_print_date($datelimit,'day'); - if ($datelimit < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $objp->am) + if ($datelimit < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $paiement) { print img_warning($langs->trans('Late')); } @@ -3894,17 +3892,17 @@ else print ''.price($objp->total_ttc).''.price($objp->am).''.price($paiement).''; - print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am,$objp->type); + print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$paiement,$objp->type); print " 
'.price($objp->total_ttc).''.price($objp->am); + $paiement = $facturestatic->getSommePaiement(); + print ''.price($paiement); if ($creditnotes) print '+'.price($creditnotes); if ($deposits) print '+'.price($deposits); print ''.price(price2num($objp->total_ttc - $objp->am - $creditnotes - $deposits,'MT')).''.price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits,'MT')).''; @@ -422,7 +422,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P $total+=$objp->total; $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + $totalrecu+=$paiement; $totalrecucreditnote+=$creditnotes; $totalrecudeposits+=$deposits; $i++;