Qual: Nettoyage des paramètres avant traitement
This commit is contained in:
parent
53afd680a1
commit
7e7c3b4f47
@ -896,33 +896,17 @@ class Facture
|
|||||||
*/
|
*/
|
||||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
|
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
|
||||||
{
|
{
|
||||||
|
dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
{
|
{
|
||||||
|
// Nettoyage paramètres
|
||||||
/* Lecture du rang max de la facture */
|
if (strlen(trim($qty))==0) $qty=1;
|
||||||
|
|
||||||
$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)
|
|
||||||
{
|
|
||||||
$qty=1;
|
|
||||||
}
|
|
||||||
$remise = 0;
|
$remise = 0;
|
||||||
$_price = $pu;
|
$_price = $pu;
|
||||||
$subprice = $pu;
|
$subprice = $pu;
|
||||||
|
|
||||||
$remise_percent = trim($remise_percent);
|
$remise_percent = trim($remise_percent);
|
||||||
|
|
||||||
if ($this->socidp)
|
if ($this->socidp)
|
||||||
{
|
{
|
||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
@ -933,29 +917,39 @@ class Facture
|
|||||||
$remise_percent = $remise_client ;
|
$remise_percent = $remise_client ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = ($pu * $remise_percent / 100);
|
$remise = ($pu * $remise_percent / 100);
|
||||||
$_price = ($pu - $remise);
|
$_price = ($pu - $remise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Formatage des prix */
|
// 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatage des prix
|
||||||
$_price = ereg_replace(",",".",$_price);
|
$_price = ereg_replace(",",".",$_price);
|
||||||
$subprice = ereg_replace(",",".",$subprice);
|
$subprice = ereg_replace(",",".",$subprice);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet ";
|
$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, fk_code_ventilation, rang)";
|
$sql .= " (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, 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 .= ",".$ventil;
|
$sql .= ",".$ventil;
|
||||||
$sql .=",".($rangmax + 1).")";
|
$sql .=",".($rangmax + 1).")";
|
||||||
|
|
||||||
if ( $this->db->query( $sql) )
|
if ( $this->db->query( $sql) )
|
||||||
{
|
{
|
||||||
$this->updateprice($facid);
|
$this->updateprice($facid);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user