Consolidation du code

This commit is contained in:
Rodolphe Quiedeville 2003-09-08 10:59:50 +00:00
parent e929a2d9ae
commit 67a7b0b0ed

View File

@ -72,7 +72,8 @@ class Propal
if ($this->statut == 0) if ($this->statut == 0)
{ {
$prod = new Product($this->db, $idproduct); $prod = new Product($this->db, $idproduct);
$prod->fetch($idproduct); if ($prod->fetch($idproduct) > 0)
{
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description) VALUES "; $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description) VALUES ";
$sql .= " (".$this->id.",". $idproduct.",". $qty.",". $prod->price.",".$prod->tva_tx.",'".$prod->label."') ; "; $sql .= " (".$this->id.",". $idproduct.",". $qty.",". $prod->price.",".$prod->tva_tx.",'".$prod->label."') ; ";
@ -86,7 +87,12 @@ class Propal
} }
else else
{ {
return 0; return -1;
}
}
else
{
return -2;
} }
} }
} }
@ -105,15 +111,20 @@ class Propal
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$this->update_price($this->id); if ($this->update_price($this->id) > 0)
{
return 1; return 1;
} }
else
{
return -1;
}
}
else else
{ {
print $this->db->error(); print $this->db->error();
print "<br>".$sql; print "<br>".$sql;
return 0; return -2;
} }
} }
} }
@ -276,9 +287,14 @@ class Propal
* *
*/ */
$sql = "UPDATE llx_propal set price=$totalht, tva=$totaltva, total=$totalttc, remise=$total_remise WHERE rowid = $rowid"; $sql = "UPDATE llx_propal set price=$totalht, tva=$totaltva, total=$totalttc, remise=$total_remise WHERE rowid = $rowid";
if (! $this->db->query($sql) ) if ( $this->db->query($sql) )
{
return 1;
}
else
{ {
print "Erreur mise à jour du prix<p>".$sql; print "Erreur mise à jour du prix<p>".$sql;
return -1;
} }
} }
} }