From ef2ad8b59ba4957826d7950033ffe02edb482ca7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Charl=C3=A8ne=20Benke?=
<1179011+defrance@users.noreply.github.com>
Date: Wed, 24 Apr 2024 21:11:37 +0200
Subject: [PATCH] add typent filter on thirdparty (#29443)
---
htdocs/compta/stats/cabyprodserv.php | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index 198a0e3d646..18b0781fa06 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
@@ -68,6 +69,7 @@ if (!$sortfield) {
$selected_cat = GETPOST('search_categ', 'intcomma');
$selected_catsoc = GETPOST('search_categ_soc', 'intcomma');
$selected_soc = GETPOST('search_soc', 'intcomma');
+$typent_id = GETPOST('typent_id', 'int');
$subcat = false;
if (GETPOST('subcat', 'alpha') === 'yes') {
$subcat = true;
@@ -207,6 +209,9 @@ if (!empty($selected_soc)) {
if (!empty($selected_type)) {
$tableparams['search_type'] = $selected_type;
}
+if (!empty($typent_id)) {
+ $tableparams['typent_id'] = $typent_id;
+}
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
// Adding common parameters
@@ -301,7 +306,9 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= ",".MAIN_DB_PREFIX."facturedet as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
-
+ if ($typent_id >0) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
+ }
$parameters = array();
$hookmanager->executeHooks('printFieldListFrom', $parameters);
$sql .= $hookmanager->resPrint;
@@ -393,6 +400,11 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($selected_soc > 0) {
$sql .= " AND f.fk_soc = ".((int) $selected_soc);
}
+
+ if ($typent_id >0) {
+ $sql .= " AND soc.fk_typent = ".((int) $typent_id);
+ }
+
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$parameters = array();
@@ -461,6 +473,12 @@ if ($modecompta == 'CREANCES-DETTES') {
print '
';
print img_picto('', 'category', 'class="pictofixedwidth"');
print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort"));
+ // type of thirdparty
+ print ' ';
+ print $langs->trans("Type").': ';
+ $formcompany = new FormCompany($db);
+ print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1);
+
print '
';
print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty"));