From 4ba31ae52eb627d68aa0e9449c290a37867444d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 19:40:56 +0100 Subject: [PATCH] Debug missing column packaging --- htdocs/fourn/class/fournisseur.product.class.php | 14 +++++++++----- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 ++ .../mysql/tables/llx_product_fournisseur_price.sql | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 64fbabedb2b..67343e549b2 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -522,10 +522,11 @@ class ProductFournisseur extends Product $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; + $sql .= " p.ref as product_ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE pfp.rowid = ".(int) $rowid; + $sql .= " AND pfp.fk_product = p.rowid"; dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -536,8 +537,11 @@ class ProductFournisseur extends Product { $this->product_fourn_price_id = $rowid; $this->id = $obj->fk_product; + $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; // deprecated + $this->product_id = $obj->fk_product; + $this->product_ref = $obj->product_ref; + $this->fourn_id = $obj->fk_soc; $this->fourn_ref = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; @@ -596,7 +600,7 @@ class ProductFournisseur extends Product return 0; } } else { - $this->error = $this->db->error(); + $this->error = $this->db->lasterror(); return -1; } } diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 2aebd3e5cea..2bfb4784206 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -546,3 +546,5 @@ CREATE TABLE llx_session( )ENGINE=innodb; INSERT INTO llx_boxes_def(file, entity) VALUES ('box_customers_outstanding_bill_reached.php', 1); + +ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 20d4db7492b..4e1d75dd1dd 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -50,6 +50,7 @@ create table llx_product_fournisseur_price import_key varchar(14), -- Import key delivery_time_days integer, supplier_reputation varchar(10), + packaging varchar(64), fk_multicurrency integer, multicurrency_code varchar(255),