Commit 8acc08f6 authored by Stanislas KITA's avatar Stanislas KITA Committed by Johan Cwiklinski

feat(dashaboard): new filter 'my groups'

parent db1fa648
......@@ -150,7 +150,7 @@ JAVASCRIPT;
}
static function group_tech(string $value = "0"): string {
return self::dropdown($value, 'group_tech', Group::class);
return self::dropdown($value, 'group_tech', Group::class, ['toadd' => [-1 => __("My groups")]]);
}
static function user_tech(string $value = "0"): string {
......@@ -195,7 +195,6 @@ JAVASCRIPT;
return $js.self::field($fieldname, $field, $label, $value > 0);
}
/**
* Get generic HTML for a filter
*
......
......@@ -1290,36 +1290,44 @@ class Provider extends CommonGLPI {
];
}
if (isset($apply_filters['group_tech'])
&& (int) $apply_filters['group_tech'] > 0) {
if (isset($apply_filters['group_tech'])) {
if ($DB->fieldExists($table, 'groups_id_tech')) {
$where += [
"$table.groups_id_tech" => (int) $apply_filters['group_tech']
];
} else if (in_array($table, [
Ticket::getTable(),
Change::getTable(),
Problem::getTable(),
])) {
$itemtype = getItemTypeForTable($table);
$main_item = getItemForItemtype($itemtype);
$grouplink = $main_item->grouplinkclass;
$gl_table = $grouplink::getTable();
$fk = $main_item->getForeignKeyField();
$groups_id = null;
if ((int) $apply_filters['group_tech'] > 0) {
$groups_id = (int) $apply_filters['group_tech'];
} else if ((int) $apply_filters['group_tech'] == -1) {
$groups_id = $_SESSION['glpigroups'];
}
$join += [
"$gl_table as gl" => [
'ON' => [
'gl' => $fk,
$table => 'id',
if ($groups_id != null) {
if ($DB->fieldExists($table, 'groups_id_tech')) {
$where += [
"$table.groups_id_tech" => $groups_id
];
} else if (in_array($table, [
Ticket::getTable(),
Change::getTable(),
Problem::getTable(),
])) {
$itemtype = getItemTypeForTable($table);
$main_item = getItemForItemtype($itemtype);
$grouplink = $main_item->grouplinkclass;
$gl_table = $grouplink::getTable();
$fk = $main_item->getForeignKeyField();
$join += [
"$gl_table as gl" => [
'ON' => [
'gl' => $fk,
$table => 'id',
]
]
]
];
$where += [
"gl.type" => \CommonITILActor::ASSIGN,
"gl.groups_id" => (int) $apply_filters['group_tech']
];
];
$where += [
"gl.type" => \CommonITILActor::ASSIGN,
"gl.groups_id" => $groups_id
];
}
}
}
......@@ -1367,7 +1375,6 @@ class Provider extends CommonGLPI {
return $criteria;
}
private static function getDatesCriteria(string $field = "", array $dates = []): array {
$begin = strtotime($dates[0]);
$end = strtotime($dates[1]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment