Fix: add null value in class method

This commit is contained in:
Regis Houssin 2012-07-28 18:32:54 +02:00
parent edbf104a7b
commit 1dd14d35f7
2 changed files with 105 additions and 113 deletions

View File

@ -3107,10 +3107,9 @@ class OrderLine
if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->product_type)) $this->product_type=0; if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseign<67> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3135,7 +3134,7 @@ class OrderLine
$sql.= " , total_tva=".price2num($this->total_tva).""; $sql.= " , total_tva=".price2num($this->total_tva)."";
$sql.= " , total_ttc=".price2num($this->total_ttc).""; $sql.= " , total_ttc=".price2num($this->total_ttc)."";
} }
$sql.= " , fk_product_fournisseur_price='".$this->fk_fournprice."'"; $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?$this->fk_fournprice:"null");
$sql.= " , buy_price_ht='".price2num($this->pa_ht)."'"; $sql.= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql.= " , total_localtax1=".price2num($this->total_localtax1); $sql.= " , total_localtax1=".price2num($this->total_localtax1);
$sql.= " , total_localtax2=".price2num($this->total_localtax2); $sql.= " , total_localtax2=".price2num($this->total_localtax2);
@ -3144,7 +3143,7 @@ class OrderLine
else { $sql.=' , date_start=null'; } else { $sql.=' , date_start=null'; }
if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; } if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; }
$sql.= " , product_type=".$this->product_type; $sql.= " , product_type=".$this->product_type;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); $sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang; if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;

View File

@ -618,13 +618,6 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$desc=dol_htmlcleanlastbr($desc); $desc=dol_htmlcleanlastbr($desc);
// ajout prix achat
$fk_fournprice = GETPOST('np_fournprice');
$pa_ht = GETPOST('np_buying_price');
if (!$fk_fournprice) $fk_fournprice = null;
if (!$pa_ht) $pa_ht = null;
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
@ -658,8 +651,8 @@ else if ($action == 'addline' && $user->rights->commande->creer)
-1, -1,
'', '',
GETPOST('fk_parent_line'), GETPOST('fk_parent_line'),
$fk_fournprice, GETPOST('np_fournprice'),
$pa_ht GETPOST('np_buying_price')
); );
if ($result > 0) if ($result > 0)