Skip to content
Snippets Groups Projects
Commit 32a479a8 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Supprime gestion explicite transactions multiniveau car gérer...

Fix: Supprime gestion explicite transactions multiniveau car gérer automatiquement par gestionnaire de base de donnée
parent de9fe852
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
* *
*/ */
/** \file htdocs/paiement.class.php /**
\file htdocs/paiement.class.php
\ingroup facture \ingroup facture
\brief Fichier de la classe des paiement de factures clients \brief Fichier de la classe des paiement de factures clients
\version $Revision$ \version $Revision$
...@@ -110,28 +111,15 @@ class Paiement ...@@ -110,28 +111,15 @@ class Paiement
/** /**
* \brief Création du paiement en base * \brief Création du paiement en base
* \param user object utilisateur qui crée * \param user object utilisateur qui crée
* \param no_commit le begin et le commit sont fait par l'appelant * \return int id du paiement crée, < 0 si erreur
*
*/ */
function create($user, $no_commit = 0) function create($user)
{ {
$total = 0;
$sql_err = 0; $sql_err = 0;
/*
* Insertion dans la base
*/
if ($no_commit == 0)
{
$result = $this->db->begin();
}
else
{
$result = 1;
}
if ($result) $this->db->begin();
{
$total = 0;
foreach ($this->amounts as $key => $value) foreach ($this->amounts as $key => $value)
{ {
...@@ -154,7 +142,6 @@ class Paiement ...@@ -154,7 +142,6 @@ class Paiement
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiement"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiement");
foreach ($this->amounts as $key => $value) foreach ($this->amounts as $key => $value)
...@@ -171,7 +158,6 @@ class Paiement ...@@ -171,7 +158,6 @@ class Paiement
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement_facture ".$facid); dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement_facture ".$facid);
$sql_err++; $sql_err++;
} }
} }
...@@ -190,26 +176,19 @@ class Paiement ...@@ -190,26 +176,19 @@ class Paiement
} }
if ( $total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs if ( $total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
{
if ($no_commit == 0)
{ {
$this->db->commit(); $this->db->commit();
}
dolibarr_syslog("Paiement::Create Ok Total = $total"); dolibarr_syslog("Paiement::Create Ok Total = $total");
return $this->id; return $this->id;
} }
else else
{
if ($no_commit == 0)
{ {
$this->db->rollback(); $this->db->rollback();
}
dolibarr_syslog("Paiement::Create Erreur"); dolibarr_syslog("Paiement::Create Erreur");
return -1; return -1;
} }
} }
}
/** /**
* \brief Affiche la liste des modes de paiement possible * \brief Affiche la liste des modes de paiement possible
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment