From 5a385bf1ccd2731090975ac75d7bd9c734404fc4 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 18 Jul 2019 11:53:36 +0200 Subject: [PATCH 1/8] ADD extrafields on global search --- htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/admin/product.php | 11 +++++++++++ htdocs/product/list.php | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index d4135c2273e..b759a023bf3 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -340,3 +340,4 @@ ErrorDestinationProductNotFound=Produit destination non trouvé ErrorProductCombinationNotFound=Variante du produit non trouvé ActionAvailableOnVariantProductOnly=Action disponible uniquement sur la variante du produit ProductsPricePerCustomer=Prix produit par clients +GlobalSearchOnExtrafield=Recherche globale : Appliquer la recherche sur les extrafields (Attention : les dates sont au format YYYY-MM-DD) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index a7e45d488e1..1fb2ac73fcf 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -146,6 +146,10 @@ if ($action == 'other') $value = GETPOST('activate_useProdFournDesc', 'alpha'); $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity); + + $value = GETPOST('activate_globalSearchOnExtrafield', 'alpha'); + $res = dolibarr_set_const($db, "PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD", $value,'chaine',0,'',$conf->entity); + if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); @@ -675,6 +679,13 @@ if (! empty($conf->fournisseur->enabled)) print ''; } +print ''; +print ''.$langs->trans("GlobalSearchOnExtrafield").''; +print ''; +print $form->selectyesno("activate_globalSearchOnExtrafield", (! empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD)?$conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD:0), 1); +print ''; +print ''; + if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 1a9b5fa1f6f..54a60d8e9bf 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -148,6 +148,22 @@ if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; } +//global search on extrafields +if(!empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD) && !empty($extralabels)) { + foreach($extralabels as $codeExtra => $labelExtra) { + $TExtraTypeNotHandled=array( + 'boolean', + 'select', + 'sellist', + 'radio', + 'checkbox', + 'chkbxlst', + 'link', + 'separate', + ); + if(!in_array($extrafields->attribute_type[$codeExtra], $TExtraTypeNotHandled)) $fieldstosearchall['ef.' . $codeExtra] = $labelExtra; + } +} if (empty($conf->global->PRODUIT_MULTIPRICES)) { From 03ed4eb14191aa33170abbc6aa8f18da7de5a17c Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 19 Jul 2019 14:39:30 +0200 Subject: [PATCH 2/8] modif rowspan --- 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 1fb2ac73fcf..ed0bcb88e74 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -552,7 +552,7 @@ print ' '."\n"; * Other parameters */ -$rowspan = 4; +$rowspan = 5; if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) $rowspan++; if (! empty($conf->global->MAIN_MULTILANGS)) $rowspan++; From 0ff121e7f1d51aba44675e532d2368d9644d4ff5 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 23 Jul 2019 16:51:08 +0200 Subject: [PATCH 3/8] add some new field on global search --- htdocs/product/list.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 54a60d8e9bf..a3dac45dcab 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -136,6 +136,11 @@ $fieldstosearchall = array( 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", + "p.note_public"=>"NotePublic", + "p.url"=>"PublicUrl", + "p.accountancy_code_sell"=>"AccountancyCodeSell", + "p.accountancy_code_buy"=>"AccountancyCodeBuy", + ); // multilang if (! empty($conf->global->MAIN_MULTILANGS)) @@ -148,6 +153,7 @@ if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; } + //global search on extrafields if(!empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD) && !empty($extralabels)) { foreach($extralabels as $codeExtra => $labelExtra) { From efd89588e56999ba34b3bf9ea48660a8aec74f81 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 25 Jul 2019 12:21:28 +0200 Subject: [PATCH 4/8] fix trans --- htdocs/langs/en_US/products.lang | 3 ++- htdocs/langs/fr_FR/products.lang | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 36ca0ede002..d9cf127b40d 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -340,4 +340,5 @@ ErrorCopyProductCombinations=There was an error while copying the product varian ErrorDestinationProductNotFound=Destination product not found ErrorProductCombinationNotFound=Product variant not found ActionAvailableOnVariantProductOnly=Action only available on the variant of product -ProductsPricePerCustomer=Product prices per customers \ No newline at end of file +ProductsPricePerCustomer=Product prices per customers +GlobalSearchOnExtrafield=Global search : apply on extrafields too (Warning : date format is YYYY-MM-DD) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index b759a023bf3..7ab9f7a0f03 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -339,5 +339,4 @@ ErrorCopyProductCombinations=Une erreur s'est produite lors de la copie des vari ErrorDestinationProductNotFound=Produit destination non trouvé ErrorProductCombinationNotFound=Variante du produit non trouvé ActionAvailableOnVariantProductOnly=Action disponible uniquement sur la variante du produit -ProductsPricePerCustomer=Prix produit par clients -GlobalSearchOnExtrafield=Recherche globale : Appliquer la recherche sur les extrafields (Attention : les dates sont au format YYYY-MM-DD) +ProductsPricePerCustomer=Prix produit par clients \ No newline at end of file From 9a0e0fbdd2a03e3fc9ebf80cdbcb6303be719157 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jul 2019 18:01:16 +0200 Subject: [PATCH 5/8] Update product.php --- htdocs/product/admin/product.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index ed0bcb88e74..ae911c04b81 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -147,8 +147,8 @@ if ($action == 'other') $value = GETPOST('activate_useProdFournDesc', 'alpha'); $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity); - $value = GETPOST('activate_globalSearchOnExtrafield', 'alpha'); - $res = dolibarr_set_const($db, "PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD", $value,'chaine',0,'',$conf->entity); + //$value = GETPOST('activate_globalSearchOnExtrafield', 'alpha'); + //$res = dolibarr_set_const($db, "PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD", $value,'chaine',0,'',$conf->entity); if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; @@ -679,12 +679,12 @@ if (! empty($conf->fournisseur->enabled)) print ''; } -print ''; +/*print ''; print ''.$langs->trans("GlobalSearchOnExtrafield").''; print ''; print $form->selectyesno("activate_globalSearchOnExtrafield", (! empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD)?$conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD:0), 1); print ''; -print ''; +print '';*/ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { From 0c6499f1935d4ed030dbd5379ab376ebe815a25c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jul 2019 18:01:47 +0200 Subject: [PATCH 6/8] 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 ae911c04b81..464ab169456 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -552,7 +552,7 @@ print ' '."\n"; * Other parameters */ -$rowspan = 5; +$rowspan = 4; if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) $rowspan++; if (! empty($conf->global->MAIN_MULTILANGS)) $rowspan++; From bd2f5ba037ff02c713a560f229696110fcd7257c Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 26 Jul 2019 14:16:54 +0200 Subject: [PATCH 7/8] FIX Replace conf by hidden conf editable by user --- htdocs/product/admin/product.php | 9 --------- htdocs/product/list.php | 23 ++--------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 464ab169456..279265b8e96 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -147,9 +147,6 @@ if ($action == 'other') $value = GETPOST('activate_useProdFournDesc', 'alpha'); $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity); - //$value = GETPOST('activate_globalSearchOnExtrafield', 'alpha'); - //$res = dolibarr_set_const($db, "PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD", $value,'chaine',0,'',$conf->entity); - if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); @@ -679,12 +676,6 @@ if (! empty($conf->fournisseur->enabled)) print ''; } -/*print ''; -print ''.$langs->trans("GlobalSearchOnExtrafield").''; -print ''; -print $form->selectyesno("activate_globalSearchOnExtrafield", (! empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD)?$conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD:0), 1); -print ''; -print '';*/ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index a3dac45dcab..460e9d5ee45 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -136,10 +136,6 @@ $fieldstosearchall = array( 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", - "p.note_public"=>"NotePublic", - "p.url"=>"PublicUrl", - "p.accountancy_code_sell"=>"AccountancyCodeSell", - "p.accountancy_code_buy"=>"AccountancyCodeBuy", ); // multilang @@ -153,23 +149,8 @@ if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; } - -//global search on extrafields -if(!empty($conf->global->PRODUIT_GLOBAL_SEARCH_ON_EXTRAFIELD) && !empty($extralabels)) { - foreach($extralabels as $codeExtra => $labelExtra) { - $TExtraTypeNotHandled=array( - 'boolean', - 'select', - 'sellist', - 'radio', - 'checkbox', - 'chkbxlst', - 'link', - 'separate', - ); - if(!in_array($extrafields->attribute_type[$codeExtra], $TExtraTypeNotHandled)) $fieldstosearchall['ef.' . $codeExtra] = $labelExtra; - } -} +// Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel' +if (! empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); if (empty($conf->global->PRODUIT_MULTIPRICES)) { From 56bc7b62ff0b4e5069ffc0bd22a26d9acaa20d96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Aug 2019 20:25:08 +0200 Subject: [PATCH 8/8] Update products.lang --- htdocs/langs/en_US/products.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index d9cf127b40d..73e672284de 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -341,4 +341,3 @@ ErrorDestinationProductNotFound=Destination product not found ErrorProductCombinationNotFound=Product variant not found ActionAvailableOnVariantProductOnly=Action only available on the variant of product ProductsPricePerCustomer=Product prices per customers -GlobalSearchOnExtrafield=Global search : apply on extrafields too (Warning : date format is YYYY-MM-DD)