From ba0e9c0c1931694e0cc9c515087b4e39f9ecf9d5 Mon Sep 17 00:00:00 2001 From: fhenry <florian.henry@open-concept.pro> Date: Tue, 23 Apr 2013 14:02:29 +0200 Subject: [PATCH] Fix [ bug #843 ] Erreur SQL box_stock fix [ bug #842 ] Erreur SQL Propal --- htdocs/comm/propal/class/propal.class.php | 11 +++++++---- htdocs/core/boxes/box_produits_alerte_stock.php | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8e3e4748f05..75d66c2065f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2631,10 +2631,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 +2651,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; diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 26e7bd003b5..651361b1e45 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); -- GitLab