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
* *
@ -367,38 +374,50 @@ class Facture
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
$sql = "DELETE FROM llx_facturedet WHERE fk_facture = $rowid;";
$sql = "DELETE FROM llx_co_fa WHERE fk_facture = $rowid;";
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
$sql = "DELETE FROM llx_facture WHERE rowid = $rowid AND fk_statut = 0;"; $sql = "DELETE FROM llx_facturedet WHERE fk_facture = $rowid;";
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
return 1; $sql = "DELETE FROM llx_facture WHERE rowid = $rowid AND fk_statut = 0;";
if ($this->db->query( $sql) )
{
return 1;
}
else
{
print "Err : ".$this->db->error();
return -1;
}
} }
else else
{ {
print "Err : ".$this->db->error(); print "Err : ".$this->db->error();
return -1; return -2;
} }
} }
else else
{ {
print "Err : ".$this->db->error(); print "Err : ".$this->db->error();
return -2; return -3;
} }
} }
else else
{ {
print "Err : ".$this->db->error(); print "Err : ".$this->db->error();
return -3; return -4;
} }
} }
else else
{ {
print "Err : ".$this->db->error(); print "Err : ".$this->db->error();
return -4; return -5;
} }
} }
/** /**