Fix: Supprime gestion explicite transactions multiniveau car gérer automatiquement par gestionnaire de base de donnée
This commit is contained in:
parent
de9fe85246
commit
32a479a834
@ -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$
|
||||||
@ -109,107 +110,85 @@ 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)
|
||||||
{
|
{
|
||||||
$sql_err = 0;
|
$total = 0;
|
||||||
/*
|
$sql_err = 0;
|
||||||
* Insertion dans la base
|
|
||||||
*/
|
$this->db->begin();
|
||||||
if ($no_commit == 0)
|
|
||||||
{
|
foreach ($this->amounts as $key => $value)
|
||||||
$result = $this->db->begin();
|
{
|
||||||
}
|
$facid = $key;
|
||||||
else
|
$value = trim($value);
|
||||||
{
|
$amount = ereg_replace(",",".",round($value, 2));
|
||||||
$result = 1;
|
|
||||||
}
|
if (is_numeric($amount))
|
||||||
|
{
|
||||||
if ($result)
|
$total += $amount;
|
||||||
{
|
}
|
||||||
$total = 0;
|
}
|
||||||
|
|
||||||
foreach ($this->amounts as $key => $value)
|
$total = ereg_replace(",",".",$total);
|
||||||
{
|
|
||||||
$facid = $key;
|
if ($total <> 0) /* On accepte les montants négatifs pour les rejets de prélèvement */
|
||||||
$value = trim($value);
|
{
|
||||||
$amount = ereg_replace(",",".",round($value, 2));
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)";
|
||||||
|
$sql .= " VALUES (now(), $this->datepaye, '$total', $this->paiementid, '$this->num_paiement', '$this->note', $user->id)";
|
||||||
if (is_numeric($amount))
|
|
||||||
{
|
if ( $this->db->query($sql) )
|
||||||
$total += $amount;
|
{
|
||||||
}
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiement");
|
||||||
}
|
|
||||||
|
foreach ($this->amounts as $key => $value)
|
||||||
$total = ereg_replace(",",".",$total);
|
{
|
||||||
|
$facid = $key;
|
||||||
if ($total <> 0) /* On accepte les montants négatifs pour les rejets de prélèvement */
|
$value = trim($value);
|
||||||
{
|
$amount = ereg_replace(",",".",round($value, 2));
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)";
|
|
||||||
$sql .= " VALUES (now(), $this->datepaye, '$total', $this->paiementid, '$this->num_paiement', '$this->note', $user->id)";
|
if (is_numeric($amount) && $amount <> 0)
|
||||||
|
{
|
||||||
if ( $this->db->query($sql) )
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
|
||||||
{
|
$sql .= " VALUES ('".$facid."','". $this->id."','". $amount."')";
|
||||||
|
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiement");
|
if (! $this->db->query($sql) )
|
||||||
|
{
|
||||||
foreach ($this->amounts as $key => $value)
|
dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement_facture ".$facid);
|
||||||
{
|
$sql_err++;
|
||||||
$facid = $key;
|
}
|
||||||
$value = trim($value);
|
}
|
||||||
$amount = ereg_replace(",",".",round($value, 2));
|
else
|
||||||
|
{
|
||||||
if (is_numeric($amount) && $amount <> 0)
|
dolibarr_syslog("Paiement::Create Montant non numérique");
|
||||||
{
|
}
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
|
}
|
||||||
$sql .= " VALUES ('".$facid."','". $this->id."','". $amount."')";
|
|
||||||
|
}
|
||||||
if (! $this->db->query($sql) )
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement_facture ".$facid);
|
dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement");
|
||||||
|
$sql_err++;
|
||||||
$sql_err++;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
if ( $total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Paiement::Create Montant non numérique");
|
$this->db->commit();
|
||||||
}
|
dolibarr_syslog("Paiement::Create Ok Total = $total");
|
||||||
}
|
return $this->id;
|
||||||
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
$this->db->rollback();
|
||||||
dolibarr_syslog("Paiement::Create Erreur INSERT dans paiement");
|
dolibarr_syslog("Paiement::Create Erreur");
|
||||||
$sql_err++;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
if ( $total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
|
|
||||||
{
|
|
||||||
if ($no_commit == 0)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
|
||||||
}
|
|
||||||
dolibarr_syslog("Paiement::Create Ok Total = $total");
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($no_commit == 0)
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
}
|
|
||||||
dolibarr_syslog("Paiement::Create Erreur");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affiche la liste des modes de paiement possible
|
* \brief Affiche la liste des modes de paiement possible
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user