From 77552fa32ae0fa5e3882980f5712318a0c6835e3 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 7 Jul 2022 10:17:56 +0200 Subject: [PATCH 1/7] FIX : We must remove empty values of $features array in fetchByProductCombination2ValuePairs() because some products can use only several attributes in their variations and not necessarily all. In this case, fetch doesn't work without my correction --- htdocs/variants/class/ProductCombination.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index ac9d5403671..c4c660e61d8 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -602,6 +602,8 @@ class ProductCombination $prodcomb2val = new ProductCombination2ValuePair($this->db); $prodcomb = new ProductCombination($this->db); + $features = array_filter($features); + foreach ($features as $attr => $attr_val) { $actual_comp[$attr] = $attr_val; } From f10788e4c6c50ee60f8722b4cb8d88720d34c121 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 7 Jul 2022 10:24:39 +0200 Subject: [PATCH 2/7] fix export resource type filter --- htdocs/core/modules/modResource.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0478cdff2a7..82ee03a4df7 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -238,20 +238,22 @@ class modResource extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r] = array(array("resource", "read")); - $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification"); - $this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text'); - $this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource"); + $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.rowid'=>'ResourceType', 'c.label'=>'ResourceTypeLabel', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification"); + $this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text','r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.rowid'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text'); + $this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.rowid'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource"); + $keyforselect = 'resource'; $keyforelement = 'resource'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.code = r.fk_code_type_resource'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid'; $this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')'; + // Imports //-------- $r = 0; From 787f52fd7f463cdcc7622ae7e8423974071f19e6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 8 Jul 2022 09:32:20 +0200 Subject: [PATCH 3/7] FIX : with callback function --- htdocs/variants/class/ProductCombination.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index c4c660e61d8..7d90c1b247d 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -602,7 +602,9 @@ class ProductCombination $prodcomb2val = new ProductCombination2ValuePair($this->db); $prodcomb = new ProductCombination($this->db); - $features = array_filter($features); + $features = array_filter($features, function($v) { + return !empty($v); + }); foreach ($features as $attr => $attr_val) { $actual_comp[$attr] = $attr_val; From 04fd17347e78e480fc99cb1e2d8cc2d1fa326568 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 8 Jul 2022 07:36:09 +0000 Subject: [PATCH 4/7] Fixing style errors. --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 7d90c1b247d..472c474c81c 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -602,7 +602,7 @@ class ProductCombination $prodcomb2val = new ProductCombination2ValuePair($this->db); $prodcomb = new ProductCombination($this->db); - $features = array_filter($features, function($v) { + $features = array_filter($features, function ($v) { return !empty($v); }); From d375c9fbbe7fc44c07c5c6d31aa0ef57ddf91c3d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 8 Jul 2022 10:35:43 +0200 Subject: [PATCH 5/7] FIX : backport commit 5b3fcc5e43979b1b0789bf81fb8f1b2b59c93056, chkbxlst cannot be emptied --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 6e4f6892e05..3d10525c568 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2072,7 +2072,7 @@ class ExtraFields if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) { continue; } - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') { + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) { //when unticking boolean field, it's not set in POST continue; } From 226488b7edeb0f89f1740537b1b9dd1dd0837951 Mon Sep 17 00:00:00 2001 From: jpb Date: Fri, 8 Jul 2022 12:32:17 +0200 Subject: [PATCH 6/7] rank change. if we only have one order we leave the origin rank otherwhise we pass -1 --- htdocs/core/actions_massactions.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 70b79ffbefc..56492276c73 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -604,7 +604,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $nb_bills_created = 0; $db->begin(); - + $nbOrders = is_array($orders) ? count($orders) : 1; foreach ($orders as $id_order) { $cmd = new Commande($db); @@ -726,7 +726,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } - + $rankedLine = ($nbOrders > 1) ? -1 : $lines[$i]->rang; $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -744,7 +744,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders 'HT', 0, $product_type, - $lines[$i]->rang, + $rankedLine, $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, From c16cd502d00b561950525206c255af6a2afe19c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Jul 2022 18:43:25 +0200 Subject: [PATCH 7/7] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 56492276c73..811e9b80d44 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -604,7 +604,9 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $nb_bills_created = 0; $db->begin(); - $nbOrders = is_array($orders) ? count($orders) : 1; + + $nbOrders = is_array($orders) ? count($orders) : 1; + foreach ($orders as $id_order) { $cmd = new Commande($db);