From 035bc32323077cb6f1b461aa1b80d07012c31208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Tue, 1 Mar 2022 16:14:31 +0100 Subject: [PATCH 1/4] Correction of the modification on the fly of the table llx_product_fournisseur_price by an addition in the script creation of the table as well as in the script of version upgrade from 12 ->13 --- htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 2 ++ .../mysql/tables/llx_product_fournisseur_price.sql | 2 +- htdocs/product/admin/product.php | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 02eb3c77d4d..a58f175e2fc 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -43,6 +43,8 @@ create table llx_commande_fournisseur_dispatch_extrafields ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande_fournisseur_dispatch_extrafields (fk_object); +ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging double(24,8) DEFAULT 1; + UPDATE llx_accounting_system SET fk_country = NULL, active = 0 WHERE pcg_version = 'SYSCOHADA'; create table llx_c_shipment_package_type diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 7e61a2df6b1..faccd8d2002 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -50,7 +50,7 @@ create table llx_product_fournisseur_price import_key varchar(14), -- Import key delivery_time_days integer, supplier_reputation varchar(10), - + packaging double(24,8) DEFAULT 1, fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_tx double(24,8) DEFAULT 1, diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 4ef011b28fc..239dba36a7a 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -150,7 +150,7 @@ if ($action == 'other') if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); - if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it + if (!$resql && $db->lasterrno() == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it { $sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN desc_fourn text"; $resql_new = $db->query($sql_new); @@ -162,10 +162,10 @@ if ($action == 'other') if ($value) { $sql_test = "SELECT count(packaging) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); - if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it + + if ($resql) // if the field does not exist, we create it { - $sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN packaging double(24,8) DEFAULT 1"; - $resql_new = $db->query($sql_new); + dol_syslog( $db->lasterrno(),LOG_ERR); } } } From f1af7ca2f226e5a0e33f20b52d66db784bb9552c Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Tue, 1 Mar 2022 16:17:32 +0100 Subject: [PATCH 2/4] Update product.php --- htdocs/product/admin/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 239dba36a7a..7c4172f7977 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -163,7 +163,7 @@ if ($action == 'other') $sql_test = "SELECT count(packaging) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); - if ($resql) // if the field does not exist, we create it + if ($resql < 0) { dol_syslog( $db->lasterrno(),LOG_ERR); } From 5c3b0847c23711678847a7c6373d26d498d7c75c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 1 Mar 2022 15:20:28 +0000 Subject: [PATCH 3/4] Fixing style errors. --- htdocs/product/admin/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 7c4172f7977..222e9ffc41f 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -165,7 +165,7 @@ if ($action == 'other') if ($resql < 0) { - dol_syslog( $db->lasterrno(),LOG_ERR); + dol_syslog($db->lasterrno(), LOG_ERR); } } } From e085c3989acc74597e9844d30952b207b3a23990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Mar 2022 14:59:55 +0100 Subject: [PATCH 4/4] Update product.php --- htdocs/product/admin/product.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 222e9ffc41f..7a2c2c6102e 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -159,15 +159,6 @@ if ($action == 'other') $value = GETPOST('activate_useProdSupplierPackaging', 'alpha'); $res = dolibarr_set_const($db, "PRODUCT_USE_SUPPLIER_PACKAGING", $value, 'chaine', 0, '', $conf->entity); - if ($value) { - $sql_test = "SELECT count(packaging) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; - $resql = $db->query($sql_test); - - if ($resql < 0) - { - dol_syslog($db->lasterrno(), LOG_ERR); - } - } } if ($action == 'specimen') // For products