Ajout lien lors de la création d'une facture depuis une commande

This commit is contained in:
Rodolphe Quiedeville 2003-11-25 12:31:13 +00:00
parent b52a9bf01e
commit 574e815a62

View File

@ -136,6 +136,13 @@ class Facture
$sql = "INSERT INTO llx_fa_pr (fk_facture, fk_propal) VALUES (".$this->id.",".$this->propalid.")"; $sql = "INSERT INTO llx_fa_pr (fk_facture, fk_propal) VALUES (".$this->id.",".$this->propalid.")";
$this->db->query($sql); $this->db->query($sql);
} }
if ($this->id && $this->commandeid)
{
$sql = "INSERT INTO llx_co_fa (fk_facture, fk_commande) VALUES (".$this->id.",".$this->commandeid.")";
$this->db->query($sql);
}
/* /*
* Produits * Produits
* *
@ -365,6 +372,11 @@ class Facture
{ {
$sql = "DELETE FROM llx_fa_pr WHERE fk_facture = $rowid;"; $sql = "DELETE FROM llx_fa_pr WHERE fk_facture = $rowid;";
if ($this->db->query( $sql) )
{
$sql = "DELETE FROM llx_co_fa WHERE fk_facture = $rowid;";
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
$sql = "DELETE FROM llx_facturedet WHERE fk_facture = $rowid;"; $sql = "DELETE FROM llx_facturedet WHERE fk_facture = $rowid;";
@ -382,6 +394,7 @@ class Facture
print "Err : ".$this->db->error(); print "Err : ".$this->db->error();
return -1; return -1;
} }
} }
else else
{ {
@ -401,6 +414,12 @@ class Facture
return -4; return -4;
} }
} }
else
{
print "Err : ".$this->db->error();
return -5;
}
}
/** /**
* Tag la facture comme payée * Tag la facture comme payée
* *