Ajout logs

This commit is contained in:
Laurent Destailleur 2008-01-25 20:25:44 +00:00
parent 15fdea2460
commit 7c5f1c1b66

View File

@ -16,9 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
@ -26,7 +23,7 @@
\ingroup facture \ingroup facture
\brief Fichier de la classe des paiement de factures clients \brief Fichier de la classe des paiement de factures clients
\remarks Cette classe est presque identique à paiementfourn.class.php \remarks Cette classe est presque identique à paiementfourn.class.php
\version $Revision$ \version $Id$
*/ */
@ -145,7 +142,7 @@ class Paiement
$sql.= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.addslashes($this->note).'\', '.$user->id.')'; $sql.= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.addslashes($this->note).'\', '.$user->id.')';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
dolibarr_syslog("Paiement::Create sql=".$sql); dolibarr_syslog("Paiement::Create insert paiement sql=".$sql);
if ($resql) if ($resql)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiement'); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiement');
@ -160,11 +157,12 @@ class Paiement
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
$sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')'; $sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')';
dolibarr_syslog("Paiement::Create sql=".$sql); dolibarr_syslog("Paiement::Create insert paiement_facture sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid); $this->error=$this->db->error();
dolibarr_syslog('Paiement::Create insert paiement_facture error='.$this->error, LOG_ERR);
$error++; $error++;
} }
} }
@ -186,21 +184,20 @@ class Paiement
} }
else else
{ {
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement'); $this->error=$this->db->error();
dolibarr_syslog('Paiement::Create insert paiement error='.$this->error, LOG_ERR);
$error++; $error++;
} }
} }
if ( $this->total <> 0 && $error == 0 ) // On accepte les montants négatifs if ($this->total <> 0 && ! $error) // On accepte les montants négatifs
{ {
$this->db->commit(); $this->db->commit();
dolibarr_syslog('Paiement::Create Ok Total = '.$this->total);
return $this->id; return $this->id;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
dolibarr_syslog('Paiement::Create Erreur');
return -1; return -1;
} }
} }