From 10f8ccd7edee81e89048f2d871a5c1aaa5ff0d45 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Wed, 30 Sep 2020 10:55:55 +0200 Subject: [PATCH 1/8] New : add two hook for more feature on list New hook are : printFieldListTable : allow to add more table on sql query (from another modules) printFieldListSearchParam : allow to keep search on new filter If ok, i add it on all native list --- htdocs/fourn/commande/list.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6be60c04249..ce596c30c65 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Frédéric France - * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2018-2020 Charlene Benke * Copyright (C) 2019 Nicolas ZABOURI * * This program is free software; you can redistribute it and/or modify @@ -522,6 +522,11 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListTable', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; @@ -638,6 +643,10 @@ if ($resql) // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + // List of mass actions available $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), From 8c017ad422163fc407c047b18032dadfb67a1be6 Mon Sep 17 00:00:00 2001 From: "geoffrey.girard" Date: Mon, 8 Aug 2016 14:44:49 +0200 Subject: [PATCH 2/8] ADD : Filters more filters on customer price tab --- .../class/productcustomerprice.class.php | 12 ++++---- htdocs/societe/price.php | 29 ++++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 2e8cd316bc0..3758cc72238 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -365,13 +365,15 @@ class Productcustomerprice extends CommonObject foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND '.$key.' = \''.$value.'\''; + $sql .= ' AND '.$key.' = \''.$this->db->escape($value).'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; - } elseif ($key == 'prod.ref') { - $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } elseif ($key == 'prod.ref' || $key == 'prod.label') { + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } elseif ($key == 't.price' || $key == 't.price_ttc') { + $sql .= ' AND ' . $key . ' LIKE \'%' . price2num($value) . '%\''; } else { - $sql .= ' AND '.$key.' = '.$value; + $sql .= ' AND '.$key.' = '.$this->db->escape($value); } } } diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index df8e966d0ce..0b1f64ac278 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -43,6 +43,9 @@ $langs->loadLangs(array("products", "companies", "bills")); $action = GETPOST('action', 'alpha'); $search_prod = GETPOST('search_prod', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_price = GETPOST('search_price'); +$search_price_ttc = GETPOST('search_price_ttc'); // Security check $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); @@ -70,7 +73,7 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $search_prod = ''; + $search_prod = $search_label = $search_price = $search_price_ttc = ''; } if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { @@ -259,6 +262,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $filter ['prod.ref'] = $search_prod; } + if (! empty($search_label)) { + $filter ['prod.label'] = $search_label; + } + + if (! empty($search_price)) { + $filter ['t.price'] = $search_price; + } + + if (! empty($search_price_ttc)) { + $filter ['t.price_ttc'] = $search_price_ttc; + } + if ($action == 'add_customer_price') { // Create mode @@ -521,7 +536,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&search_prod='.$search_prod.'&id='.$object->id; + $option = '&search_prod=' . $search_prod . '&id=' . $object->id . '&label=' . $search_label .'&price=' . $search_price . '&price_ttc=' . $search_price_ttc; print ''."\n"; @@ -534,7 +549,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -550,7 +566,11 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { { print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // Print the search button print '"; + print ""; print ""; print '"; From 1131eb240dd3ad8ed7e4be3ec363ba62554bdb63 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 30 Sep 2020 13:36:03 +0200 Subject: [PATCH 3/8] Fix lang trans --- htdocs/societe/price.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 0b1f64ac278..0e390d67b03 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -550,7 +550,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; From 399258cc86b89c76138fa9498eec556cbfac872f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 14:55:02 +0200 Subject: [PATCH 4/8] Update list.php --- htdocs/fourn/commande/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ce596c30c65..9977caa3d54 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -522,11 +522,9 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } - $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListTable', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; From 31710479dc52eb67d829a8c8a2ef698581dffb15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 14:59:18 +0200 Subject: [PATCH 5/8] Update list.php --- htdocs/fourn/commande/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 9977caa3d54..f54f8383cf3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -503,7 +503,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; @@ -523,7 +523,7 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; @@ -564,7 +564,7 @@ if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_r include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -642,7 +642,7 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; // List of mass actions available From bede4040f6ac65074ee151ad3ed85b3260843e67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 15:04:03 +0200 Subject: [PATCH 6/8] Update productcustomerprice.class.php --- htdocs/product/class/productcustomerprice.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 3758cc72238..f8b837ce472 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -252,7 +252,6 @@ class Productcustomerprice extends CommonObject $sql = "SELECT"; $sql .= " t.rowid,"; - $sql .= " t.entity,"; $sql .= " t.datec,"; $sql .= " t.tms,"; @@ -270,7 +269,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.localtax2_tx,"; $sql .= " t.fk_user,"; $sql .= " t.import_key"; - + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; $sql .= " WHERE t.rowid = ".$id; @@ -330,7 +329,6 @@ class Productcustomerprice extends CommonObject $sql = "SELECT"; $sql .= " t.rowid,"; - $sql .= " t.entity,"; $sql .= " t.datec,"; $sql .= " t.tms,"; @@ -363,8 +361,7 @@ class Productcustomerprice extends CommonObject // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { - if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year - { + if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year $sql .= ' AND '.$key.' = \''.$this->db->escape($value).'\''; } elseif ($key == 'soc.nom') { $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -373,7 +370,7 @@ class Productcustomerprice extends CommonObject } elseif ($key == 't.price' || $key == 't.price_ttc') { $sql .= ' AND ' . $key . ' LIKE \'%' . price2num($value) . '%\''; } else { - $sql .= ' AND '.$key.' = '.$this->db->escape($value); + $sql .= ' AND '.$key.' = '.((int) $value); } } } From 2ea6c092a43eb5ee7b1abda904b7170257cc1e57 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 2 Oct 2020 13:05:50 +0000 Subject: [PATCH 7/8] Fixing style errors. --- htdocs/product/class/productcustomerprice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index f8b837ce472..1553869d1f1 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -269,7 +269,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.localtax2_tx,"; $sql .= " t.fk_user,"; $sql .= " t.import_key"; - + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; $sql .= " WHERE t.rowid = ".$id; From 533fdda8485512635a28f99f07d6aa41c29f7452 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 2 Oct 2020 15:11:02 +0200 Subject: [PATCH 8/8] Update vcard.php --- htdocs/user/vcard.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 5d99a4a9e89..9d8fd6478b4 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -40,8 +40,6 @@ if ($user->socid > 0) $socid = $user->socid; $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); - $result = $user2->fetch($id); if ($result <= 0)
'.$langs->trans("Product").'' . $langs->trans("Ref") . '' . $langs->trans("product") . ''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("VAT").'
   '; $searchpicto = $form->showFilterAndCheckAddButtons(0); @@ -569,6 +589,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $staticprod->fetch($line->fk_product); print "".$staticprod->getNomUrl(1)."" . $staticprod->label ."".dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."
' . $langs->trans("Ref") . '' . $langs->trans("product") . '' . $langs->trans("Product") . ''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("VAT").'