From 08c5fd2e36af5b7b775cd7a73a35f914d58acee4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 14 Mar 2016 14:38:30 +0100 Subject: [PATCH] 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; - } + }*/ } /** -- GitLab