From 8c017ad422163fc407c047b18032dadfb67a1be6 Mon Sep 17 00:00:00 2001 From: "geoffrey.girard" Date: Mon, 8 Aug 2016 14:44:49 +0200 Subject: [PATCH 1/4] 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 2/4] 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 bede4040f6ac65074ee151ad3ed85b3260843e67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 15:04:03 +0200 Subject: [PATCH 3/4] 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 4/4] 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;
'.$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").'