Gestion de la remise produit lors de la création d'une facture
This commit is contained in:
parent
e3cf53fefe
commit
64b348e957
@ -63,10 +63,10 @@ if ($HTTP_POST_VARS["action"] == 'add')
|
|||||||
|
|
||||||
if (!$HTTP_POST_VARS["propalid"])
|
if (!$HTTP_POST_VARS["propalid"])
|
||||||
{
|
{
|
||||||
$facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"]);
|
$facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]);
|
||||||
$facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"]);
|
$facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]);
|
||||||
$facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"]);
|
$facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]);
|
||||||
$facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"]);
|
$facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]);
|
||||||
|
|
||||||
$facid = $facture->create($user);
|
$facid = $facture->create($user);
|
||||||
}
|
}
|
||||||
@ -428,11 +428,12 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<table border="0" cellspacing="0">';
|
print '<table border="0" cellspacing="0">';
|
||||||
|
print '<tr><td>Produit</td><td>Quan.</td><td>Remise</td></tr>';
|
||||||
for ($i = 1 ; $i < 5 ; $i++)
|
for ($i = 1 ; $i < 5 ; $i++)
|
||||||
{
|
{
|
||||||
print '<tr><td><select name="idprod'.$i.'">'.$opt.'</select></td>';
|
print '<tr><td><select name="idprod'.$i.'">'.$opt.'</select></td>';
|
||||||
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td></tr>';
|
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
|
||||||
|
print '<td><input type="text" size="4" name="remise_percent'.$i.'" value="0"> %</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -136,10 +136,16 @@ class Facture
|
|||||||
$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_facturedet (fk_facture, fk_product, qty, price, tva_taux, description) VALUES ";
|
$result_insert = $this->addline($this->id,
|
||||||
$sql .= " ($this->id,".$this->products[$i].",".$this->products_qty[$i].",$prod->price,$prod->tva_tx,'".addslashes($prod->libelle)."');";
|
$prod->libelle,
|
||||||
|
$prod->price,
|
||||||
|
$this->products_qty[$i],
|
||||||
|
$prod->tva_tx,
|
||||||
|
$this->products[$i],
|
||||||
|
$this->products_remise_percent[$i]);
|
||||||
|
|
||||||
if (! $this->db->query($sql) )
|
|
||||||
|
if ( $result_insert < 0)
|
||||||
{
|
{
|
||||||
print $sql . '<br>' . $this->db->error() .'<br>';
|
print $sql . '<br>' . $this->db->error() .'<br>';
|
||||||
}
|
}
|
||||||
@ -402,7 +408,7 @@ class Facture
|
|||||||
* Ajoute un produit dans la facture
|
* Ajoute un produit dans la facture
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function add_product($idproduct, $qty)
|
Function add_product($idproduct, $qty, $remise_percent)
|
||||||
{
|
{
|
||||||
if ($idproduct > 0)
|
if ($idproduct > 0)
|
||||||
{
|
{
|
||||||
@ -413,6 +419,7 @@ class Facture
|
|||||||
$qty = 1 ;
|
$qty = 1 ;
|
||||||
}
|
}
|
||||||
$this->products_qty[$i] = $qty;
|
$this->products_qty[$i] = $qty;
|
||||||
|
$this->products_remise_percent[$i] = $remise_percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user