mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
added filter in services treeview
This commit is contained in:
parent
43bcc4465f
commit
ba0c6a7ed7
@ -252,6 +252,7 @@ class TreeService extends Tree
|
|||||||
protected function getProcessedServices()
|
protected function getProcessedServices()
|
||||||
{
|
{
|
||||||
$is_favourite = $this->getServiceFavouriteFilter();
|
$is_favourite = $this->getServiceFavouriteFilter();
|
||||||
|
$service_search = $this->getServiceNameSearchFilter();
|
||||||
|
|
||||||
if (users_can_manage_group_all('AR')) {
|
if (users_can_manage_group_all('AR')) {
|
||||||
$groups_acl = '';
|
$groups_acl = '';
|
||||||
@ -259,6 +260,16 @@ class TreeService extends Tree
|
|||||||
$groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')';
|
$groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$exclude_children = 'ts.id NOT IN (
|
||||||
|
SELECT DISTINCT id_service_child
|
||||||
|
FROM tservice_element
|
||||||
|
WHERE id_server_meta = 0
|
||||||
|
)';
|
||||||
|
|
||||||
|
if ($service_search !== '') {
|
||||||
|
$exclude_children = '1=1';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT
|
'SELECT
|
||||||
ts.id,
|
ts.id,
|
||||||
@ -277,15 +288,14 @@ class TreeService extends Tree
|
|||||||
FROM tservice ts
|
FROM tservice ts
|
||||||
LEFT JOIN tservice_element tse
|
LEFT JOIN tservice_element tse
|
||||||
ON tse.id_service = ts.id
|
ON tse.id_service = ts.id
|
||||||
WHERE ts.id NOT IN (
|
WHERE %s
|
||||||
SELECT DISTINCT id_service_child
|
%s
|
||||||
FROM tservice_element
|
|
||||||
WHERE id_server_meta = 0
|
|
||||||
)
|
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
GROUP BY ts.id',
|
GROUP BY ts.id',
|
||||||
|
$exclude_children,
|
||||||
$is_favourite,
|
$is_favourite,
|
||||||
|
$service_search,
|
||||||
$groups_acl
|
$groups_acl
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -346,7 +356,12 @@ class TreeService extends Tree
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$service = new Service($this->id, true);
|
$service = new Service($this->id, true);
|
||||||
|
// hd("SRVSRVSRVSRVSRVSRV", true);
|
||||||
|
// hd($service, true);
|
||||||
|
/*
|
||||||
|
if ($this->filter['searchService'] !== '') {
|
||||||
|
$filter[] = " (tservice.name LIKE '%".$this->filter['searchService']."%' OR tservice.description LIKE '%".$this->filter['searchService']."%')";
|
||||||
|
}*/
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($service->children() as $item) {
|
foreach ($service->children() as $item) {
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
@ -704,6 +719,23 @@ class TreeService extends Tree
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve SQL filter for current filter
|
||||||
|
*
|
||||||
|
* @return string SQL filter.
|
||||||
|
*/
|
||||||
|
protected function getServiceNameSearchFilter()
|
||||||
|
{
|
||||||
|
if (isset($this->filter['searchService']) === true
|
||||||
|
&& empty($this->filter['searchService']) === false
|
||||||
|
) {
|
||||||
|
return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')";
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrites partial functionality of general Tree.class.
|
* Overwrites partial functionality of general Tree.class.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user