Merge pull request #24909 from mc2contributor/filterChildProjects

Filter child projects out of project list.
This commit is contained in:
Laurent Destailleur 2023-06-07 20:44:10 +02:00 committed by GitHub
commit da85ee4406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -124,6 +124,9 @@ if (GETPOSTISSET('formfilteraction')) {
$searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
}
$searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
$search_omitChildren = GETPOST('search_omitChildren', 'alpha') == 'on' ? 1 : 0;
}
$mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
@ -601,6 +604,12 @@ if ($search_login) {
if ($search_import_key) {
$sql .= natural_search(array('p.import_key'), $search_import_key);
}
if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
if ($search_omitChildren == 1) {
$sql .= " AND p.fk_project IS NULL";
}
}
// Search for tag/category ($searchCategoryProjectList is an array of ID)
$searchCategoryProjectList = $search_category_array;
$searchCategoryProjectOperator = 0;
@ -1018,6 +1027,11 @@ if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isMo
$moreforfilter .= '</div>';
}
if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
//Checkbox for omitting child projects filter
$moreforfilter .= '<p style="display: inline-block; margin-left: 5px;">'.$langs->trans("Omit sub-projects").' </p><input type="checkbox" style="margin-left: 10px" class="valignmiddle" id="search_omitChildren" name="search_omitChildren"'.($search_omitChildren ? ' checked="checked"' : '').'"> ';
}
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;