From 84105e996a89202a87244ec989e6a6aa64dc6b37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Oct 2020 01:03:48 +0200 Subject: [PATCH 1/4] Fix for #14940 --- htdocs/core/class/html.form.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b39ffdef879..14251ce2912 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1172,17 +1172,15 @@ class Form // On recherche les societes $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays"; } + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (!empty($user->socid)) $sql .= " AND s.rowid = ".$user->socid; if ($filter) $sql .= " AND (".$filter.")"; From 74ae9a2618394c7bf21f72be381ed1f3c443ac80 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 8 Oct 2020 10:49:46 +0200 Subject: [PATCH 2/4] FIX CA report by product/service : subcategory filter --- htdocs/compta/stats/cabyprodserv.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index f9057e1066c..b51495ad8ef 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -237,10 +237,6 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } - elseif ($selected_cat) // Into a specific category - { - $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; - } $sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; $sql.= " AND l.product_type in (0,1)"; @@ -261,10 +257,11 @@ if ($modecompta == 'CREANCES-DETTES') $sql.=" AND cp.fk_product is null"; } elseif ($selected_cat) { // Into a specific category - $sql.= " AND (c.rowid = ".$selected_cat; - if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; - $sql.= ")"; - $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; + $sql.= " AND (p.rowid IN "; + $sql.= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE cp.fk_categorie IN "; + $sql.= " (SELECT rowid FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$selected_cat; + if ($subcat) $sql.=" OR fk_parent = " . $selected_cat; + $sql.= ")))"; } if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; $sql.= " AND f.entity IN (".getEntity('invoice').")"; From 231a86683849769ea79d1bccb014f68cdbc13db2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 10 Oct 2020 07:38:29 +0200 Subject: [PATCH 3/4] FIX Loan - Return on list when you cancel create form or delete a loan --- htdocs/loan/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 3e96a33c931..2c46823afb0 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -83,7 +83,7 @@ if (empty($reshook)) if ($result > 0) { setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); - header("Location: index.php"); + header("Location: list.php"); exit; } else @@ -156,7 +156,7 @@ if (empty($reshook)) } else { - header("Location: index.php"); + header("Location: list.php"); exit(); } } From bf7d5b56fbb9000f639a8a87812e26c1eedc4bad Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 12 Oct 2020 11:50:19 +0200 Subject: [PATCH 4/4] FIX subcat filter --- htdocs/compta/stats/cabyprodserv.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index b51495ad8ef..0a30390e215 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -56,6 +56,8 @@ $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +$categorie = new Categorie($db); + // product/service $selected_type = GETPOST('search_type', 'int'); if ($selected_type =='') $selected_type = -1; @@ -257,11 +259,24 @@ if ($modecompta == 'CREANCES-DETTES') $sql.=" AND cp.fk_product is null"; } elseif ($selected_cat) { // Into a specific category + + if ($subcat) + { + $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); + + $listofcatsql = ""; + foreach ($TListOfCats as $key => $cat) + { + if ($key !== 0) $listofcatsql .= ","; + $listofcatsql .= $cat['rowid']; + } + } + $sql.= " AND (p.rowid IN "; - $sql.= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE cp.fk_categorie IN "; - $sql.= " (SELECT rowid FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$selected_cat; - if ($subcat) $sql.=" OR fk_parent = " . $selected_cat; - $sql.= ")))"; + $sql .= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE "; + if ($subcat) $sql .= "cp.fk_categorie IN (". $listofcatsql.")"; + else $sql.="cp.fk_categorie = ".$selected_cat; + $sql.= "))"; } if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; $sql.= " AND f.entity IN (".getEntity('invoice').")";