Correction bug #22757

This commit is contained in:
Rodolphe Quiedeville 2008-05-16 11:14:11 +00:00
parent fbba4c44c7
commit a5567431c0

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
@ -27,7 +27,6 @@
\version $Id$ \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
@ -42,7 +41,7 @@ $sortfield = isset($_GET['sortfield'])?$_GET['sortfield']:$_POST['sortfield'];
$sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder']; $sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder'];
$page=isset($_GET['page'])?$_GET['page']:$_POST['page']; $page=isset($_GET['page'])?$_GET['page']:$_POST['page'];
// Sécurité accés client // Sécurité accés client
$socid=0; $socid=0;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
@ -64,7 +63,7 @@ if ($action == 'add_paiement')
$_POST['reyear']); $_POST['reyear']);
$paiement_id = 0; $paiement_id = 0;
$total = 0; $total = 0;
// Génère tableau des montants amounts // Génère tableau des montants amounts
$amounts = array(); $amounts = array();
foreach ($_POST as $key => $value) foreach ($_POST as $key => $value)
{ {
@ -76,8 +75,7 @@ if ($action == 'add_paiement')
} }
} }
// Effectue les vérifications des parametres
// Effectue les vérifications des parametres
if ($_POST['paiementid'] <= 0) if ($_POST['paiementid'] <= 0)
{ {
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>'; $mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>';
@ -114,7 +112,7 @@ if ($action == 'add_paiement')
$paiement->amounts = $amounts; // Array of amounts $paiement->amounts = $amounts; // Array of amounts
$paiement->paiementid = $_POST['paiementid']; $paiement->paiementid = $_POST['paiementid'];
$paiement->num_paiement = $_POST['num_paiement']; $paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment']; $paiement->note = mysql_real_escape_string($_POST['comment']);
$paiement_id = $paiement->create($user); $paiement_id = $paiement->create($user);
if ($paiement_id > 0) if ($paiement_id > 0)
@ -134,11 +132,11 @@ if ($action == 'add_paiement')
$user); $user);
// Mise a jour fk_bank dans llx_paiement. // Mise a jour fk_bank dans llx_paiement.
// On connait ainsi le paiement qui a généré l'écriture bancaire // On connait ainsi le paiement qui a généré l'écriture bancaire
if ($bank_line_id > 0) if ($bank_line_id > 0)
{ {
$paiement->update_fk_bank($bank_line_id); $paiement->update_fk_bank($bank_line_id);
// Mise a jour liens (pour chaque facture concernées par le paiement) // Mise a jour liens (pour chaque facture concernées par le paiement)
foreach ($paiement->amounts as $key => $value) foreach ($paiement->amounts as $key => $value)
{ {
$facid = $key; $facid = $key;
@ -255,7 +253,7 @@ if ($action == 'create' || $action == 'add_paiement')
print '<tr><td colspan="2">&nbsp;</td></tr>'; print '<tr><td colspan="2">&nbsp;</td></tr>';
} }
/* /*
* Autres factures impayées * Autres factures impayées
*/ */
$sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df'; $sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df';
$sql .= ', sum(pf.amount) as am'; $sql .= ', sum(pf.amount) as am';
@ -263,7 +261,7 @@ if ($action == 'create' || $action == 'add_paiement')
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
$sql .= ' WHERE f.fk_soc = '.$facture->socid; $sql .= ' WHERE f.fk_soc = '.$facture->socid;
$sql .= ' AND f.paye = 0'; $sql .= ' AND f.paye = 0';
$sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée
$sql .= ' GROUP BY f.facnumber'; $sql .= ' GROUP BY f.facnumber';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)