diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index bdbd0b49b59..709ff7aff70 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -96,9 +96,16 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
{
$facturefourn = new FactureFournisseur($db);
$factfournid = $_GET['facid'];
- $facturefourn->delete($factfournid);
- Header('Location: index.php');
- exit;
+ $result=$facturefourn->delete($factfournid);
+ if ($result > 0)
+ {
+ Header('Location: index.php');
+ exit;
+ }
+ else
+ {
+ $mesg='
'.$facturefourn->error.'
';
+ }
}
}
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index 9051c50efd3..dc1e1c97ad3 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -333,20 +333,21 @@ class FactureFournisseur extends Facture
}
/**
- * \brief Supprime la facture
- * \param rowid id de la facture � supprimer
+ * \brief Delete invoice in database
+ * \param rowid Id of invoice to delete
+ * \return int <0 if KO, >0 if OK
*/
function delete($rowid)
{
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
- dolibarr_syslog("FactureFournisseur sql=".$sql);
+ dolibarr_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid.' AND fk_statut = 0';
- dolibarr_syslog("FactureFournisseur sql=".$sql);
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
+ dolibarr_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG);
$resql2 = $this->db->query($sql);
if ($resql2)
{
@@ -357,14 +358,16 @@ class FactureFournisseur extends Facture
{
$this->db->rollback();
$this->error=$this->db->lasterror();
- dolibarr_syslog("FactureFournisseur::delete ".$this->error);
+ dolibarr_syslog("FactureFournisseur::delete ".$this->error, LOG_ERR);
+ return -1;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
- dolibarr_syslog("FactureFournisseur::delete ".$this->error);
+ dolibarr_syslog("FactureFournisseur::delete ".$this->error, LOG_ERR);
+ return -1;
}
}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index f92b7a561dd..6d7fc2802b1 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -844,7 +844,7 @@ class Propal extends CommonObject
else
{
$this->error=$this->db->error();
- dolibarr_syslog("Propal::Fetch Error ".$this->error, LOG_ERROR);
+ dolibarr_syslog("Propal::Fetch Error ".$this->error, LOG_ERR);
return -1;
}
}