Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add thirdparty category filter #29313

Merged
merged 2 commits into from Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions htdocs/compta/stats/cabyprodserv.php
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -65,6 +66,7 @@

// Category
$selected_cat = GETPOSTINT('search_categ');
$selected_catsoc = (int) GETPOST('search_categ_soc', 'int');
$selected_soc = GETPOSTINT('search_soc');
$subcat = false;
if (GETPOST('subcat', 'alpha') === 'yes') {
Expand Down Expand Up @@ -196,6 +198,9 @@
if (!empty($selected_cat)) {
$tableparams['search_categ'] = $selected_cat;
}
if (!empty($selected_catsoc)) {
$tableparams['search_categ_soc'] = $selected_catsoc;
}
if (!empty($selected_soc)) {
$tableparams['search_soc'] = $selected_soc;
}
Expand Down Expand Up @@ -303,6 +308,9 @@
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);
Expand Down Expand Up @@ -346,6 +354,14 @@
}
$sql .= "))";
}
if ($selected_catsoc === -2) { // Without any category
$sql .= " AND ct.fk_soc is null";
} elseif ($selected_catsoc > 0) { // Into a specific category
$sql .= " AND (soc.rowid IN ";
$sql .= " (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ct WHERE ";
$sql .= "ct.fk_categorie = ".((int) $selected_catsoc);
$sql .= "))";
}
if ($selected_soc > 0) {
$sql .= " AND soc.rowid=".((int) $selected_soc);
}
Expand Down Expand Up @@ -415,6 +431,9 @@

//select thirdparty
print '</br>';
print img_picto('', 'category', 'class="paddingrightonly"');
print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort"));
print '</br>';
print img_picto('', 'company', 'class="paddingrightonly"');
print $form->select_thirdparty_list($selected_soc, 'search_soc', '', $langs->trans("ThirdParty"));
print '</td>';
Expand Down