group filter custom field view

This commit is contained in:
daniel 2018-12-04 09:36:48 +01:00
parent a03adb1762
commit 222da4ee40
2 changed files with 12 additions and 3 deletions

View File

@ -460,6 +460,7 @@ if($build_table_save_filter){
$table->class = 'databox';
$array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select(
$array_filters, 'id_name',
@ -491,7 +492,7 @@ if($append_tab_filter){
$table->data[0][2] = __('Group');
$table->data[0][3] = html_print_select_groups(
$config['id_user'], 'AR', true, 'group_search',
$config['id_user'], 'AR', true, 'group_search_cr',
0, '', '', '0', true, false,
false, '', false, '', false, false,
'id_grupo', false

View File

@ -506,8 +506,16 @@ function agent_counters_custom_fields($filters){
}
function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){
//filter group and check ACL groups
$groups_and = "";
if (!users_can_manage_group_all()) {
$user_groups = array_keys(users_get_groups(false, "AR", false));
$id_groups = implode(", ", $user_groups);
$groups_and = " AND (group_search IN ($id_groups)) ";
}
if($for_select){
$query = "SELECT id, `name` FROM tagent_custom_fields_filter";
$query = "SELECT id, `name` FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and;
$rs = db_get_all_rows_sql($query);
if(isset($rs) && is_array($rs)){
foreach ($rs as $key => $value) {
@ -519,7 +527,7 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""
}
}
else{
$query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1";
$query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and;
if($id){
$query .= " AND id = " . $id;