From 5e74bd4db8882c990dd329a31474721891ea46ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Apr 2024 19:45:49 +0200 Subject: [PATCH] Fix filter on company. --- htdocs/compta/stats/cabyprodserv.php | 33 ++++++--------------------- htdocs/core/class/html.form.class.php | 18 ++++++++++----- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index d7b4aaaa5ad..b58ccbe9a83 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/stats/cabyprodserv.php - * \brief Page reporting TO by Products & Services + * \brief Page reporting Turnover billed by Products & Services */ // Load Dolibarr environment @@ -299,19 +299,8 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - if ($selected_soc > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)"; - } $sql .= ",".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - /* - if ($selected_cat === -2) { // Without any category - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; - } - if ($selected_catsoc === -2) { // Without any category - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_societe as ct ON soc.rowid = ct.fk_soc"; - } - */ $parameters = array(); $hookmanager->executeHooks('printFieldListFrom', $parameters); @@ -337,15 +326,10 @@ if ($modecompta == 'CREANCES-DETTES') { $searchCategoryProductList = array($selected_cat); if ($subcat) { $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); - - $listofcatsql = ""; + $searchCategoryProductList = array(); foreach ($TListOfCats as $key => $cat) { - if ($key !== 0) { - $listofcatsql .= ","; - } - $listofcatsql .= $cat['rowid']; + $searchCategoryProductList[] = $cat['rowid']; } - $searchCategoryProductList = explode(',', $listofcatsql); } if (!empty($searchCategoryProductList)) { $searchCategoryProductSqlList = array(); @@ -407,7 +391,7 @@ if ($modecompta == 'CREANCES-DETTES') { } if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".((int) $selected_soc); + $sql .= " AND f.fk_soc = ".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; @@ -464,16 +448,14 @@ if ($modecompta == 'CREANCES-DETTES') { print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', 0, $langs->trans("Category")); print ' '; - print $langs->trans("SubCats").'? '; - print ''; + print ''; // type filter (produit/service) - print ' '; - print $langs->trans("Type").': '; - $form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', 1, 1, 1); + $form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', $langs->trans("Type"), 1, 1); //select thirdparty print '
'; @@ -482,7 +464,6 @@ if ($modecompta == 'CREANCES-DETTES') { print '
'; print img_picto('', 'company', 'class="pictofixedwidth"'); print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty")); - //print $form->select_thirdparty_list($selected_soc, 'search_soc', '', $langs->trans("ThirdParty")); print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 69e74aab4d3..7c96c34a295 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1148,11 +1148,11 @@ class Form * Return list of types of lines (product or service) * Example: 0=product, 1=service, 9=other (for external module) * - * @param string $selected Preselected type - * @param string $htmlname Name of field in html form - * @param int<0,1> $showempty Add an empty field - * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) - * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') + * @param string $selected Preselected type + * @param string $htmlname Name of field in html form + * @param int<0,1>|string $showempty Add an empty field + * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) + * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') * @return void */ public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) @@ -1172,7 +1172,13 @@ class Form if ($selected == -1) { print ' selected'; } - print '> '; + print '>'; + if (is_numeric($showempty)) { + print ' '; + } else { + print $showempty; + } + print ''; } print '