Gestion de la tva par ligne

This commit is contained in:
Rodolphe Quiedeville 2003-06-27 12:27:37 +00:00
parent 0152c4fa72
commit ca9e407177

View File

@ -72,8 +72,8 @@ class Propal
$prod = new Product($this->db, $idproduct); $prod = new Product($this->db, $idproduct);
$prod->fetch($idproduct); $prod->fetch($idproduct);
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price) VALUES "; $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx) VALUES ";
$sql .= " (".$this->id.",". $idproduct.",". $qty.", $prod->price) ; "; $sql .= " (".$this->id.",". $idproduct.",". $qty.",". $prod->price.",".$prod->tva_tx.") ; ";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
@ -127,7 +127,8 @@ class Propal
* *
* *
*/ */
Function create() { Function create()
{
/* /*
* Insertion dans la base * Insertion dans la base
*/ */
@ -135,27 +136,32 @@ class Propal
$sql .= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0, $this->datep, now(), '$this->ref', $this->author, '$this->note')"; $sql .= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0, $this->datep, now(), '$this->ref', $this->author, '$this->note')";
$sqlok = 0; $sqlok = 0;
if ( $this->db->query($sql) ) { if ( $this->db->query($sql) )
{
$this->id = $this->db->last_insert_id(); $this->id = $this->db->last_insert_id();
$sql = "SELECT rowid FROM llx_propal WHERE ref='$this->ref';"; $sql = "SELECT rowid FROM llx_propal WHERE ref='$this->ref';";
if ( $this->db->query($sql) ) { if ( $this->db->query($sql) )
{
/* /*
* Insertion du detail des produits dans la base * Insertion du detail des produits dans la base
*/ */
if ( $this->db->num_rows() ) { if ( $this->db->num_rows() )
{
$propalid = $this->db->result( 0, 0); $propalid = $this->db->result( 0, 0);
$this->db->free(); $this->db->free();
for ($i = 0 ; $i < sizeof($this->products) ; $i++) { for ($i = 0 ; $i < sizeof($this->products) ; $i++)
{
$prod = new Product($this->db, $this->products[$i]); $prod = new Product($this->db, $this->products[$i]);
$prod->fetch($this->products[$i]); $prod->fetch($this->products[$i]);
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price) VALUES "; $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx) VALUES ";
$sql .= " ($propalid,". $this->products[$i].",". $this->products_qty[$i].", $prod->price) ; "; $sql .= " ($propalid,".$this->products[$i].",".$this->products_qty[$i].",$prod->price,$prod->tva_tx);";
if (! $this->db->query($sql) ) { if (! $this->db->query($sql) )
{
print $sql . '<br>' . $this->db->error() .'<br>'; print $sql . '<br>' . $this->db->error() .'<br>';
} }
} }
@ -166,15 +172,20 @@ class Propal
/* /*
* Affectation au projet * Affectation au projet
*/ */
if ($this->projetidp) { if ($this->projetidp)
{
$sql = "UPDATE llx_propal SET fk_projet=$this->projetidp WHERE ref='$this->ref';"; $sql = "UPDATE llx_propal SET fk_projet=$this->projetidp WHERE ref='$this->ref';";
$this->db->query($sql); $this->db->query($sql);
} }
} }
} else { }
else
{
print $this->db->error() . '<b><br>'.$sql; print $this->db->error() . '<b><br>'.$sql;
} }
} else { }
else
{
print $this->db->error() . '<b><br>'.$sql; print $this->db->error() . '<b><br>'.$sql;
} }
return $this->id; return $this->id;
@ -253,7 +264,7 @@ class Propal
* Lignes * Lignes
*/ */
$sql = "SELECT d.qty, p.description, p.ref, p.price"; $sql = "SELECT d.qty, p.description, p.ref, p.price, d.tva_tx";
$sql .= " FROM llx_propaldet as d, llx_product as p"; $sql .= " FROM llx_propaldet as d, llx_product as p";
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid"; $sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid";
@ -270,6 +281,7 @@ class Propal
$ligne->desc = stripslashes($objp->description); $ligne->desc = stripslashes($objp->description);
$ligne->qty = $objp->qty; $ligne->qty = $objp->qty;
$ligne->ref = $objp->ref; $ligne->ref = $objp->ref;
$ligne->tva_tx = $objp->tva_tx;
$ligne->price = $objp->price; $ligne->price = $objp->price;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
$i++; $i++;