From 08c5fd2e36af5b7b775cd7a73a35f914d58acee4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Mar 2016 14:38:30 +0100 Subject: [PATCH 1/3] FIX #4809 - Duplicate functions with different content --- htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/class/commande.class.php | 12 +++++++----- htdocs/compta/facture/class/facture.class.php | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0159e767ff3..bca97f09188 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2803,6 +2803,8 @@ class Propal extends CommonObject */ function getLinesArray() { + // For other object, here we call fetch_lines. But fetch_lines does not exists on proposal + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3137cd9c7dc..85d5c5cebc4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1702,7 +1702,7 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; $sql.= ' WHERE l.fk_commande = '.$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; - $sql .= ' ORDER BY l.rang'; + $sql .= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $result = $this->db->query($sql); @@ -3233,12 +3233,14 @@ class Commande extends CommonOrder } /** - * Return an array of order lines - * - * @return array Lines of order + * Create an array of order lines + * + * @return int >0 if OK, <0 if KO */ function getLinesArray() { + return $this->fetch_lines(); + /* $lines = array(); $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx, '; @@ -3308,7 +3310,7 @@ class Commande extends CommonOrder { $this->error=$this->db->error(); return -1; - } + }*/ } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 614c7d3f33a..d2fdf68172c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1097,7 +1097,7 @@ class Facture extends CommonInvoice $this->lines=array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; - $sql .= ' l.situation_percent, l.fk_prev_id,'; + $sql.= ' l.situation_percent, l.fk_prev_id,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.date_start as date_start, l.date_end as date_end,'; @@ -1107,7 +1107,7 @@ class Facture extends CommonInvoice $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang'; + $sql.= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -3474,6 +3474,8 @@ class Facture extends CommonInvoice */ function getLinesArray() { + return $this->fetch_lines(); + /* $sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,'; $sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,'; $sql .= ' l.situation_percent, l.fk_prev_id,'; @@ -3506,11 +3508,12 @@ class Facture extends CommonInvoice $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->ref = $obj->product_ref; - $this->lines[$i]->entity = $obj->entity; // Product entity - $this->lines[$i]->product_label = $obj->product_label; + $this->lines[$i]->product_ref = $obj->product_ref; + $this->lines[$i]->product_label = $obj->product_label; $this->lines[$i]->product_desc = $obj->product_desc; $this->lines[$i]->fk_product_type = $obj->fk_product_type; $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->entity = $obj->entity; // Product entity $this->lines[$i]->qty = $obj->qty; $this->lines[$i]->subprice = $obj->subprice; $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; @@ -3520,6 +3523,10 @@ class Facture extends CommonInvoice $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->localtax1_tx = $obj->localtax1_tx; + $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; + $this->lines[$i]->localtax1_type = $obj->localtax1_type; + $this->lines[$i]->localtax2_type = $obj->localtax2_type; $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->situation_percent = $obj->situation_percent; $this->lines[$i]->fk_prev_id = $obj->fk_prev_id; @@ -3544,7 +3551,7 @@ class Facture extends CommonInvoice { $this->error=$this->db->error(); return -1; - } + }*/ } /** From aa7eb4935c5d4c60a115408d4ca64501e5968fcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Mar 2016 12:18:47 +0100 Subject: [PATCH 2/3] FIX VAT rate can be negative. Example spain selling to morroco. --- htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_proforma.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index 6729ea2a60c..acd3ddc1109 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -922,7 +922,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c29054cde54..849eeceac48 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -911,7 +911,7 @@ class pdf_einstein extends ModelePDFCommandes // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 7e5190dc5e6..50d62ee983f 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -818,7 +818,7 @@ class pdf_proforma extends ModelePDFCommandes // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 9716b6bd968..719449bcbd4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1107,7 +1107,7 @@ class pdf_crabe extends ModelePDFFactures // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 818f6fdb560..f8e6874f3b2 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1073,7 +1073,7 @@ class pdf_azur extends ModelePDFPropales // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; From 19e3c1b0894102ca8f3933894d5d23457bc591d2 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 17 Mar 2016 16:35:23 +0100 Subject: [PATCH 3/3] FIX finished parameters not used --- htdocs/product/ajax/products.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 0d4cbda9fc2..c17fdb65aea 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -48,6 +48,7 @@ $price_level = GETPOST('price_level', 'int'); $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); $price_by_qty_rowid = GETPOST('pbq', 'int'); +$finished = GETPOST('finished', 'int'); /* * View @@ -180,7 +181,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $form = new Form($db); if (empty($mode) || $mode == 1) { - $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid); + $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); }