Fix: pgsql compatibility

This commit is contained in:
Regis Houssin 2010-04-17 08:22:29 +00:00
parent 0daea22e9b
commit d7ffb431a7
3 changed files with 17 additions and 18 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copytight (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* 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"]))

View File

@ -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 '<table class="nobordernopadding"><tr class="nocellnopadd">';
@ -3882,7 +3880,7 @@ else
// Date limit
print '<td align="center" nowrap="1">'.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 '<td align="right">'.price($objp->total_ttc).'</td>';
print '<td align="right">'.price($objp->am).'</td>';
print '<td align="right">'.price($paiement).'</td>';
// Affiche statut de la facture
print '<td align="right" nowrap="nowrap">';
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 "</td>";
//print "<td>&nbsp;</td>";
print "</tr>\n";
$total+=$objp->total;
$total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am;
$totalrecu+=$paiement;
$i++;
}

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
*
* 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 '<td align="right">'.price($objp->total_ttc).'</td>';
// Recu
print '<td align="right">'.price($objp->am);
$paiement = $facturestatic->getSommePaiement();
print '<td align="right">'.price($paiement);
if ($creditnotes) print '+'.price($creditnotes);
if ($deposits) print '+'.price($deposits);
print '</td>';
// Reste a payer
print '<td align="right">'.price(price2num($objp->total_ttc - $objp->am - $creditnotes - $deposits,'MT')).'</td>';
print '<td align="right">'.price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits,'MT')).'</td>';
// Montant
print '<td align="right">';
@ -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++;