bugfix: on supprime d'abord les lignes de facture et ensuite la facture

This commit is contained in:
Regis Houssin 2006-05-30 08:49:39 +00:00
parent 1d68f59416
commit 49a924d5bd

View File

@ -254,14 +254,11 @@ class FactureFournisseur extends Facture
*/
function delete($rowid)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid.' AND fk_statut = 0;';
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->affected_rows($resql);
if ($num)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid.' AND fk_statut = 0;';
$resql2 = $this->db->query($sql);
if ($resql2)
{
@ -271,7 +268,6 @@ class FactureFournisseur extends Facture
{
dolibarr_print_error($this->db);
}
}
}
else
{