diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2ce1af4241b..43593353622 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Éric Seigne - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * * 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 @@ -22,7 +22,8 @@ * */ -/*! \file htdocs/compta/facture.php +/** + \file htdocs/compta/facture.php \ingroup facture \brief Page de création d'une facture \version $Revision$ @@ -220,7 +221,7 @@ if ($_POST["action"] == 'add') * */ -if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->facture->valider) +if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == "yes" && $user->rights->facture->valider) { $fac = new Facture($db); $fac->fetch($_GET["facid"]); @@ -771,13 +772,16 @@ else /* */ /* *************************************************************************** */ { + if ($_GET["facid"] > 0) { $fac = New Facture($db); if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) - { + { + $soc = new Societe($db, $fac->socidp); $soc->fetch($fac->socidp); + $author = new User($db); $author->id = $fac->user_author; $author->fetch(); @@ -1574,9 +1578,8 @@ else $sql .= " f.rowid DESC "; $sql .= $db->plimit($limit+1,$offset); - + $result = $db->query($sql); - } if ($result) { @@ -1589,7 +1592,7 @@ else } print_barre_liste("Factures client".($socidp?" $soc->nom":""),$page,"facture.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); - + $i = 0; print ''; print ''; @@ -1629,7 +1632,7 @@ else while ($i < min($num,$limit)) { - $objp = $db->fetch_object(); + $objp = $db->fetch_object($result); $var=!$var; print ""; @@ -1720,6 +1723,9 @@ else { dolibarr_print_error($db); } + + } + } } diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 363a7ac8015..112d6dbf7ce 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Benoit Mortier * * 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 @@ -23,7 +23,8 @@ * */ -/*! \file htdocs/facture.class.php +/** + \file htdocs/facture.class.php \ingroup facture \brief Fichier de la classe des factures clients \version $Revision$ @@ -291,11 +292,12 @@ class Facture $sql .= " AND f.fk_soc = ".$societe_id; } - if ($this->db->query($sql) ) + $result=$this->db->query($sql); + if ($result) { - if ($this->db->num_rows()) + if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object(); + $obj = $this->db->fetch_object($result); $this->id = $rowid; $this->datep = $obj->dp; @@ -335,15 +337,15 @@ class Facture $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise, l.remise_percent, l.subprice, ".$this->db->pdate("l.date_start")." as date_start,".$this->db->pdate("l.date_end")." as date_end"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l WHERE l.fk_facture = ".$this->id; - $result = $this->db->query($sql); - if ($result) + $result2 = $this->db->query($sql); + if ($result2) { $num = $this->db->num_rows(); $i = 0; $total = 0; while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result2); $faclig = new FactureLigne($this->db); $faclig->desc = stripslashes($objp->description); $faclig->qty = $objp->qty; @@ -379,7 +381,7 @@ class Facture { //dolibarr_print_error($this->db); dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid Erreur dans fetch de la facture"); - } + } } /**