Gestion du rang lors de l'ajout d'un produit
This commit is contained in:
parent
402aa6d568
commit
1bfd900de0
@ -863,6 +863,21 @@ class Facture
|
|||||||
{
|
{
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* Lecture du rang max de la facture */
|
||||||
|
|
||||||
|
$sql = "SELECT max(rang) FROM ".MAIN_DB_PREFIX."facturedet";
|
||||||
|
$sql .= " WHERE fk_facture =".$facid;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row($resql);
|
||||||
|
$rangmax = $row[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -- */
|
||||||
|
|
||||||
if (strlen(trim($qty))==0)
|
if (strlen(trim($qty))==0)
|
||||||
{
|
{
|
||||||
$qty=1;
|
$qty=1;
|
||||||
@ -884,7 +899,6 @@ class Facture
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = ($pu * $remise_percent / 100);
|
$remise = ($pu * $remise_percent / 100);
|
||||||
@ -895,14 +909,16 @@ class Facture
|
|||||||
$_price = ereg_replace(",",".",$_price);
|
$_price = ereg_replace(",",".",$_price);
|
||||||
$subprice = ereg_replace(",",".",$subprice);
|
$subprice = ereg_replace(",",".",$subprice);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet ";
|
||||||
|
$sql .= " (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, rang)";
|
||||||
$sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', ";
|
$sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', ";
|
||||||
|
|
||||||
if ($datestart) { $sql.= "'$datestart', "; }
|
if ($datestart) { $sql.= "'$datestart', "; }
|
||||||
else { $sql.=" null, "; }
|
else { $sql.=" null, "; }
|
||||||
if ($dateend) { $sql.= "'$dateend' "; }
|
if ($dateend) { $sql.= "'$dateend' "; }
|
||||||
else { $sql.=" null "; }
|
else { $sql.=" null "; }
|
||||||
$sql.=")";
|
|
||||||
|
$sql.=",".($rangmax + 1).")";
|
||||||
|
|
||||||
if ( $this->db->query( $sql) )
|
if ( $this->db->query( $sql) )
|
||||||
{
|
{
|
||||||
@ -911,7 +927,7 @@ class Facture
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user