diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8e3e4748f05bbcfe084b6743bb64ca6b4d2a8f8b..237050928fc424a1bebfc767262fa156041e1d34 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -310,7 +310,7 @@ class Propal extends CommonObject * * @see add_product */ - function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='') + function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='') { global $conf; @@ -466,7 +466,7 @@ class Propal extends CommonObject * @param int $type 0/1=Product/service * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0) { global $conf,$user,$langs; @@ -2615,6 +2615,7 @@ class PropaleLigne if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2631,10 +2632,13 @@ class PropaleLigne // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; - $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; + $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type,'; + $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; - $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang)'; + $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2,'; + $sql.= ' total_ttc, fk_product_fournisseur_price, buy_price_ht,'; + $sql.= ' special_code, rang)'; $sql.= " VALUES (".$this->fk_propal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -2648,13 +2652,13 @@ class PropaleLigne $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " ".($this->subprice?price2num($this->subprice):'null').","; $sql.= " ".price2num($this->remise_percent).","; - $sql.= " '".$this->info_bits."',"; + $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; $sql.= " ".price2num($this->total_tva).","; $sql.= " ".price2num($this->total_localtax1).","; $sql.= " ".price2num($this->total_localtax2).","; $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".(isset($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").","; + $sql.= " ".(!empty($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").","; $sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").","; $sql.= ' '.$this->special_code.','; $sql.= ' '.$this->rang; @@ -2752,6 +2756,7 @@ class PropaleLigne if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_parent_line)) $this->fk_fournprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2784,13 +2789,13 @@ class PropaleLigne $sql.= " , total_localtax1=".price2num($this->total_localtax1).""; $sql.= " , total_localtax2=".price2num($this->total_localtax2).""; } - $sql.= " , fk_product_fournisseur_price='".$this->fk_fournprice."'"; - $sql.= " , buy_price_ht='".price2num($this->pa_ht)."'"; + $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null"); + $sql.= " , buy_price_ht=".price2num($this->pa_ht); if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " WHERE rowid = ".$this->rowid; - + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1222a5bdb4a857087c279e99083cfe2d403e509b..3afacfb243e08f3b30b0a799a2684bbdb0246030 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -210,7 +210,7 @@ if ($search_user > 0) } if (! $sall) { - $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.increment, f.total, f.total_ttc,'; + $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.increment, f.total,f.tva, f.total_ttc,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut, f.note,'; $sql.= ' s.nom, s.rowid'; diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 26e7bd003b58a88ad4339567cc870431130d3bbf..651361b1e457944e5eb508b6e32c1b4ae2add471 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -82,6 +82,7 @@ class box_produits_alerte_stock extends ModeleBoxes $sql.= " AND p.tosell = 1"; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql.= " GROUP BY p.rowid, p.seuil_stock_alerte, s.reel"; $sql.= " HAVING s.reel < p.seuil_stock_alerte"; $sql.= $db->order('s.reel', 'DESC'); $sql.= $db->plimit($max, 0);