Exemplo n.º 1
0
function form_search_incident($return = false, $filter = false)
{
    include_once "functions_user.php";
    global $config;
    $output = '';
    if (!$filter) {
        $search_string = (string) get_parameter('search_string');
        $status = (int) get_parameter('search_status', -10);
        $priority = (int) get_parameter('search_priority', -1);
        $resolution = (int) get_parameter('search_resolution', -1);
        $id_group = (int) get_parameter('search_id_group');
        $id_inventory = (int) get_parameter('search_id_inventory');
        $id_company = (int) get_parameter('search_id_company');
        $search_id_user = (string) get_parameter('search_id_user');
        $search_id_incident_type = (int) get_parameter('search_id_incident_type');
        $date_from = (int) get_parameter("search_from_date");
        $date_start = (string) get_parameter("search_first_date");
        $date_end = (string) get_parameter("search_last_date");
        $search_creator = (string) get_parameter('search_id_creator');
        $search_editor = (string) get_parameter('search_editor');
        $search_closed_by = (string) get_parameter('search_id_creator');
        $group_by_project = (bool) get_parameter('search_group_by_project');
        $sla_state = (int) get_parameter('search_sla_state', 0);
        $id_task = (int) get_parameter('search_id_task', 0);
        $left_sla = (int) get_parameter('search_left_sla', 0);
        $right_sla = (int) get_parameter('search_right_sla', 0);
        $show_hierarchy = (bool) get_parameter('show_hierarchy');
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        foreach ($type_fields as $key => $type_field) {
            $search_type_field[$type_field['id']] = (string) get_parameter('search_type_field_' . $type_field['id']);
        }
    } else {
        $search_string = (string) $filter['string'];
        $priority = (int) $filter['priority'];
        $id_group = (int) $filter['id_group'];
        $status = (int) $filter['status'];
        $resolution = (int) $filter['resolution'];
        $id_company = (int) $filter['id_company'];
        $id_inventory = (int) $filter['id_inventory'];
        $search_id_incident_type = (int) $filter['id_incident_type'];
        $search_id_user = (string) $filter['id_user'];
        $date_from = (int) $filter['from_date'];
        $date_start = (string) $filter['first_date'];
        $date_end = (string) $filter['last_date'];
        $search_creator = (string) $filter['id_creator'];
        $search_editor = (string) $filter['editor'];
        $search_closed_by = (string) $filter['closed_by'];
        $group_by_project = (bool) $filter['group_by_project'];
        $sla_state = (int) $filter['sla_state'];
        $id_task = (int) $filter['id_task'];
        $left_sla = (int) $filter['left_sla'];
        $right_sla = (int) $filter['right_sla'];
        $show_hierarchy = (bool) $filter['show_hierarchy'];
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        if ($type_fields) {
            foreach ($type_fields as $key => $type_field) {
                $search_type_field[$type_field['id']] = (string) $filter['type_field_' . $type_field['id']];
            }
        }
    }
    /* No action is set, so the form will be sent to the current page */
    $table = new stdclass();
    $table->width = "99%";
    $table->class = "search-table-button";
    $table->cellspacing = 2;
    $table->cellpadding = 2;
    $table->data = array();
    $table->size = array();
    $table->style = array();
    $table->style[0] = 'width: 25%';
    $table->style[1] = 'width: 25%';
    $table->style[2] = 'width: 25%; vertical-align:text-top;';
    $table->style[3] = 'width: 25%';
    $table->rowstyle = array();
    $table->rowstyle[1] = 'display: none';
    $table->rowstyle[2] = 'display: none';
    $table->rowstyle[3] = 'display: none';
    $table->rowstyle[4] = 'display: none';
    $table->rowstyle[5] = 'display: none';
    $table->rowstyle[6] = 'text-align: right';
    $table->colspan = array();
    $table->colspan[0][0] = 2;
    $table->colspan[6][0] = 4;
    $table->colspan[7][1] = 3;
    $table->rowspan = array();
    $table->rowspan[2][2] = 2;
    $table->data[0][0] = print_input_text('search_string', $search_string, '', 50, 100, true, __('Search string'));
    $available_status = get_indicent_status();
    $available_status[-10] = __("Not closed");
    $table->data[0][1] = print_select($available_status, 'search_status', $status, '', __('Any'), 0, true, false, true, __('Status'));
    $groups = users_get_groups_for_select($config['id_user'], "IW", true, true);
    $table->data[0][2] = print_select($groups, 'search_id_group', $id_group, '', '', '', true, false, false, __('Group'));
    $table->data[0][3] = print_checkbox_extended('search_show_hierarchy', 1, $show_hierarchy, false, '', '', true, __('Show hierarchy'));
    $params_owner = array();
    $params_owner['input_id'] = 'text-search_id_user';
    $params_owner['input_name'] = 'search_id_user';
    $params_owner['input_value'] = $search_id_user;
    $params_owner['title'] = __('Owner');
    $params_owner['return'] = true;
    $table->data[1][0] = user_print_autocomplete_input($params_owner);
    $params_editor = array();
    $params_editor['input_id'] = 'text-search_editor';
    $params_editor['input_name'] = 'search_editor';
    $params_editor['input_value'] = $search_editor;
    $params_editor['title'] = __('Editor');
    $params_editor['return'] = true;
    $table->data[1][1] = user_print_autocomplete_input($params_editor);
    $params_closed_by = array();
    $params_closed_by['input_id'] = 'text-search_closed_by';
    $params_closed_by['input_name'] = 'search_closed_by';
    $params_closed_by['input_value'] = $search_closed_by;
    $params_closed_by['title'] = __('Closed by');
    $params_closed_by['return'] = true;
    $table->data[1][2] = user_print_autocomplete_input($params_closed_by);
    $params_creator = array();
    $params_creator['input_id'] = 'text-search_id_creator';
    $params_creator['input_name'] = 'search_id_creator';
    $params_creator['input_value'] = $search_creator;
    $params_creator['title'] = __('Creator');
    $params_creator['return'] = true;
    $table->data[1][3] = user_print_autocomplete_input($params_creator);
    $table->data[2][0] = print_select(get_priorities(), 'search_priority', $priority, '', __('Any'), -1, true, false, false, __('Priority'), false);
    $table->data[2][1] = print_select(get_incident_resolutions(), 'search_resolution', $resolution, '', __('Any'), -1, true, false, false, __('Resolution'), false);
    $table->data[2][2] = get_last_date_control($date_from, 'search_from_date', __('Date'), $date_start, 'search_first_date', __('Created from'), $date_end, 'search_last_date', __('Created to'));
    $name = $id_inventory ? get_inventory_name($id_inventory) : '';
    $table->data[2][3] = print_input_text('inventory_name', $name, '', 7, 0, true, __('Inventory'), false);
    $table->data[2][3] .= "&nbsp;&nbsp;<a href='javascript: show_search_inventory(\"\",\"\",\"\",\"\",\"\",\"\");'>" . print_image('images/zoom.png', true, array('title' => __('Search inventory'))) . "</a>";
    $table->data[2][3] .= print_input_hidden('id_inventory', $id_inventory, true);
    if (!get_external_user($config["id_user"])) {
        $table->data[4][0] = print_select(get_companies(), 'search_id_company', $id_company, '', __('All'), 0, true, false, false, __('Company'));
    }
    $table->data[4][1] = print_select(get_incident_types(), 'search_id_incident_type', $search_id_incident_type, 'javascript:change_type_fields_table();', __('All'), 0, true, false, false, __('Ticket type'));
    $table->data[4][3] = print_checkbox_extended('search_group_by_project', 1, $group_by_project, false, '', '', true, __('Group by project/task'));
    $sla_states = array();
    $sla_states[1] = __('SLA is fired');
    $sla_states[2] = __('SLA is not fired');
    $table->data[5][0] = print_select($sla_states, 'search_sla_state', $sla_state, '', __('All'), 0, true, false, false, __('SLA'));
    $table->data[5][1] = combo_task_user_participant($config["id_user"], 0, $id_task, true, __("Task"), 'search_id_task');
    $table->data[5][2] = print_input_text('search_left_sla', $left_sla, '', 7, 0, true, __('SLA > (%)'), false);
    $table->data[5][3] = print_input_text('search_right_sla', $right_sla, '', 7, 0, true, __('SLA < (%)'), false);
    $table_type_fields = new stdclass();
    $table_type_fields->width = "100%";
    $table_type_fields->class = "search-table";
    $table_type_fields->data = array();
    //Print custom field data
    $column = 0;
    $row = 0;
    if ($type_fields) {
        foreach ($type_fields as $key => $type_field) {
            $data = $search_type_field[$type_field['id']];
            if ($type_field['type'] == "text" || $type_field['type'] == "textarea") {
                $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
            } else {
                if ($type_field['type'] == "combo") {
                    $combo_values = explode(",", $type_field['combo_value']);
                    $values = array();
                    foreach ($combo_values as $value) {
                        $values[$value] = $value;
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, '', __('Any'), '', true, false, false, $type_field['label']);
                } else {
                    if ($type_field['type'] == "linked") {
                        $linked_values = explode(",", $type_field['linked_value']);
                        $values = array();
                        foreach ($linked_values as $value) {
                            $value_without_parent = preg_replace("/^.*\\|/", "", $value);
                            $values[$value_without_parent] = $value_without_parent;
                            $has_childs = get_db_all_rows_sql("SELECT * FROM tincident_type_field WHERE parent=" . $type_field['id']);
                            if ($has_childs) {
                                $i = 0;
                                foreach ($has_childs as $child) {
                                    if ($i == 0) {
                                        $childs = $child['id'];
                                    } else {
                                        $childs .= ',' . $child['id'];
                                    }
                                    $i++;
                                }
                                $childs = "'" . $childs . "'";
                                $script = 'javascript:change_linked_type_fields_table(' . $childs . ',' . $type_field['id'] . ');';
                            } else {
                                $script = '';
                            }
                        }
                        $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, $script, __('Any'), '', true, false, false, $type_field['label']);
                    }
                }
            }
            $table_type_fields->data[$row][$column] = $input;
            if ($column >= 3) {
                $column = 0;
                $row++;
            } else {
                $column++;
            }
        }
    }
    if ($table_type_fields->data) {
        $table_type_fields_html = print_table($table_type_fields, true);
    }
    $table->data[6][0] = "<div id='table_type_fields'>" . $table_type_fields_html . "</div>";
    $table->data[7][0] = '<div style="width: 100%; text-align: left; height: 20px;"><a class="show_advanced_search" id="show_advanced_search" href="javascript:show_ad_search();">' . __('Advanced search') . '></a></div>';
    //Store serialize filter
    serialize_in_temp($filter, $config["id_user"]);
    $table->data[7][2] = print_submit_button(__('Search'), 'search', false, 'class="sub search"', true);
    $table->data[7][2] .= print_button(__('Export to CSV'), '', false, 'window.open(\'' . 'include/export_csv.php?export_csv_tickets=1' . '\')', 'class="sub csv"', true);
    $table->colspan[7][2] = 4;
    $output .= '<form id="search_incident_form" method="post" action="index.php?sec=incidents&sec2=operation/incidents/incident_search">';
    $output .= print_table($table, true);
    $output .= '</form>';
    echo "<div class= 'dialog ui-dialog-content' id='search_inventory_window'></div>";
    if ($return) {
        return $output;
    }
    echo $output;
}
Exemplo n.º 2
0
 echo "<br>";
 $custom_search = get_custom_search($id_search, 'incidents');
 if ($custom_search) {
     if ($custom_search["form_values"]) {
         $filter = unserialize($custom_search["form_values"]);
         $filter_form = $filter;
         echo '<h3 class="suc">' . sprintf(__('Custom search "%s" loaded'), $custom_search["name"]) . '</h3>';
     } else {
         echo '<h3 class="error">' . sprintf(__('Could not load "%s" custom search'), $custom_search["name"]) . '</h3>';
     }
 } else {
     echo '<h3 class="error">' . __('Could not load custom search') . '</h3>';
 }
 include "incident_statistics.php";
 if ($show_list) {
     $statuses = get_indicent_status();
     $resolutions = get_incident_resolutions();
     $table->class = 'listing';
     $table->width = "99%";
     $table->style = array();
     $table->style[0] = 'font-weight: bold';
     $table->head = array();
     $table->head[0] = __('ID');
     $table->head[1] = __('SLA');
     $table->head[2] = __('% SLA');
     $table->head[3] = __('Ticket');
     $table->head[4] = __('Group') . "<br><em>" . __("Company") . "</em>";
     $table->head[5] = __('Status') . "<br /><em>" . __('Resolution') . "</em>";
     $table->head[6] = __('Priority');
     $table->head[7] = __('Updated') . "<br /><em>" . __('Started') . "</em>";
     $table->head[8] = __('Responsible');
Exemplo n.º 3
0
function incidents_get_filter_tickets_tree($filters, $mode = false, $limit = false)
{
    global $config;
    /* Set default values if none is set */
    $filters['string'] = isset($filters['string']) ? $filters['string'] : '';
    $filters['status'] = isset($filters['status']) ? $filters['status'] : -10;
    $filters['priority'] = isset($filters['priority']) ? $filters['priority'] : -1;
    $filters['id_group'] = isset($filters['id_group']) ? $filters['id_group'] : -1;
    $filters['id_company'] = isset($filters['id_company']) ? $filters['id_company'] : 0;
    $filters['id_inventory'] = isset($filters['id_inventory']) ? $filters['id_inventory'] : 0;
    $filters['id_incident_type'] = isset($filters['id_incident_type']) ? $filters['id_incident_type'] : 0;
    $filters['id_user'] = isset($filters['id_user']) ? $filters['id_user'] : '';
    $filters['id_user_or_creator'] = isset($filters['id_user_or_creator']) ? $filters['id_user_or_creator'] : '';
    $filters['from_date'] = isset($filters['from_date']) ? $filters['from_date'] : 0;
    $filters['first_date'] = isset($filters['first_date']) ? $filters['first_date'] : '';
    $filters['last_date'] = isset($filters['last_date']) ? $filters['last_date'] : '';
    $filters['id_creator'] = isset($filters['id_creator']) ? $filters['id_creator'] : '';
    $filters['editor'] = isset($filters['editor']) ? $filters['editor'] : '';
    $filters['closed_by'] = isset($filters['closed_by']) ? $filters['closed_by'] : '';
    $filters['resolution'] = isset($filters['resolution']) ? $filters['resolution'] : '';
    $filters["offset"] = isset($filters['offset']) ? $filters['offset'] : 0;
    $filters["group_by_project"] = isset($filters['group_by_project']) ? $filters['group_by_project'] : 0;
    $filters["id_task"] = isset($filters['id_task']) ? $filters['id_task'] : -1;
    $filters["sla_state"] = isset($filters['sla_state']) ? $filters['sla_state'] : 0;
    $filters["left_sla"] = isset($filters['left_sla']) ? $filters['left_sla'] : 0;
    $filters["right_sla"] = isset($filters['right_sla']) ? $filters['right_sla'] : 0;
    $filters["show_hierarchy"] = isset($filters['show_hierarchy']) ? $filters['show_hierarchy'] : 0;
    if (empty($filters['status'])) {
        $filters['status'] = implode(',', array_keys(get_indicent_status()));
    }
    // Not closed
    if ($filters["status"] == -10) {
        $filters['status'] = "1,2,3,4,5,6";
    }
    $resolutions = get_incident_resolutions();
    $sql_clause = '';
    if ($filters['priority'] != -1) {
        $sql_clause .= sprintf(' AND prioridad = %d', $filters['priority']);
    }
    if ($filters['id_group'] != 1) {
        if ($filters["show_hierarchy"]) {
            $children = groups_get_childrens($filters['id_group']);
            $ids = $filters['id_group'];
            foreach ($children as $child) {
                $ids .= "," . $child['id_grupo'];
            }
            $sql_clause .= " AND id_grupo IN (" . $ids . ")";
        } else {
            $sql_clause .= sprintf(' AND id_grupo = %d', $filters['id_group']);
        }
    }
    if (!empty($filters['id_user'])) {
        $sql_clause .= sprintf(' AND id_usuario = "%s"', $filters['id_user']);
    }
    if (!empty($filters['id_user_or_creator'])) {
        $sql_clause .= sprintf(' AND (id_usuario = "%s" OR id_creator = "%s")', $filters['id_user_or_creator'], $filters['id_user_or_creator']);
    }
    if (!empty($filters['resolution']) && $filters['resolution'] > -1) {
        $sql_clause .= sprintf(' AND resolution = %d', $filters['resolution']);
    }
    if ($filters['id_task'] == 0) {
        $sql_clause .= sprintf(' AND id_task = 0');
    } else {
        if ($filters['id_task'] != -1) {
            $sql_clause .= sprintf(' AND id_task = %d', $filters['id_task']);
        }
    }
    //Incident type 0 means all and incident type -1 means without type
    if ($filters["id_incident_type"] != -1) {
        if ($filters["id_incident_type"]) {
            $sql_clause .= sprintf(' AND id_incident_type = %d', $filters['id_incident_type']);
        }
        $incident_fields = array();
        foreach ($filters as $key => $value) {
            // If matchs an incident field, ad an element to the array with their real id and its data
            if (preg_match("/^type_field_/", $key)) {
                $incident_fields[preg_replace("/^type_field_/", "", $key)] = $value;
            }
        }
        foreach ($incident_fields as $id => $data) {
            if ($data !== "") {
                $sql_clause .= sprintf(' AND id_incidencia = ANY (SELECT id_incident
																	FROM tincident_field_data
																	WHERE id_incident_field = "%s"
																		AND data LIKE "%%%s%%")', $id, $data);
            }
        }
    }
    if (!empty($filters['from_date']) && $filters['from_date'] > 0) {
        $last_date_seconds = $filters['from_date'] * 24 * 60 * 60;
        $filters['first_date'] = date('Y-m-d H:i:s', time() - $last_date_seconds);
        $sql_clause .= sprintf(' AND inicio >= "%s"', $filters['first_date']);
        $filters['last_date'] = "";
    } else {
        if (!empty($filters['first_date'])) {
            $time = strtotime($filters['first_date']);
            //00:00:00 to set date at the beginig of the day
            $sql_clause .= sprintf(' AND inicio >= "%s"', date("Y-m-d 00:00:00", $time));
        }
        if (!empty($filters['last_date'])) {
            $time = strtotime($filters['last_date']);
            if (!empty($filters['first_date'])) {
                //23:59:59 to set date at the end of day
                $sql_clause .= sprintf(' AND inicio <= "%s"', date("Y-m-d 23:59:59", $time));
            } else {
                $time_from = strtotime($filters['first_date']);
                if ($time_from < $time) {
                    $sql_clause .= sprintf(' AND inicio <= "%s"', date("Y-m-d", $time));
                }
            }
        }
    }
    if (!empty($filters['id_creator'])) {
        $sql_clause .= sprintf(' AND id_creator = "%s"', $filters['id_creator']);
    }
    if (!empty($filters['editor'])) {
        $sql_clause .= sprintf(' AND editor = "%s"', $filters['editor']);
    }
    if (!empty($filters['closed_by'])) {
        $sql_clause .= sprintf(' AND closed_by = "%s"', $filters['closed_by']);
    }
    if (!empty($filters['sla_state'])) {
        switch ($filters['sla_state']) {
            case 0:
                $sla_filter = ' ';
                break;
            case 1:
                $sla_filter = "AND (sla_disabled = 0 AND affected_sla_id <> 0)";
                break;
            case 2:
                $sla_filter = "AND (sla_disabled = 0 AND affected_sla_id = 0)";
                break;
        }
    }
    if ($filters['order_by'] && !is_array($filters['order_by'])) {
        $order_by_array = json_decode(clean_output($filters["order_by"]), true);
    } else {
        $order_by_array = $filters['order_by'];
    }
    //Use config block size if no other was given
    if ($limit) {
        if (!isset($filters["limit"])) {
            $filters["limit"] = $config["block_size"];
        }
    }
    $order_by = "";
    if ($order_by_array) {
        foreach ($order_by_array as $key => $value) {
            if ($value) {
                $order_by .= " {$key} {$value}, ";
            }
        }
    }
    switch ($mode) {
        case 'count':
            //Just count items
            $sql = sprintf('SELECT COUNT(id_incidencia) FROM tincidencia FD
				WHERE estado IN (%s)
				%s
				AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" 
				OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" 
				OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%"))
				%s', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter);
            $count = get_db_value_sql($sql);
            if ($count === false) {
                return 0;
            }
            return $count;
            break;
        case 'tasks':
            $sql = sprintf('SELECT id_task FROM tincidencia FD
				WHERE estado IN (%s)
				%s
				AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" 
				OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" 
				OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%"))
				%s
				GROUP BY id_task', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter);
            $tasks = get_db_all_rows_sql($sql);
            if ($tasks === false) {
                return false;
            }
            return $tasks;
            break;
        case 'tickets':
        default:
            //Select all items and return all information
            $sql = sprintf('SELECT * FROM tincidencia FD
				WHERE estado IN (%s)
				%s
				AND (titulo LIKE "%%%s%%" OR descripcion LIKE "%%%s%%" 
				OR id_creator LIKE "%%%s%%" OR id_usuario LIKE "%%%s%%" 
				OR id_incidencia IN (SELECT id_incident FROM tincident_field_data WHERE data LIKE "%%%s%%"))
				%s
				ORDER BY %s actualizacion DESC', $filters['status'], $sql_clause, $filters['string'], $filters['string'], $filters['string'], $filters['string'], $filters['string'], $sla_filter, $order_by);
            $incidents = get_db_all_rows_sql($sql);
            if ($incidents === false) {
                return false;
            }
            $result = array();
            foreach ($incidents as $incident) {
                //Check external users ACLs
                $external_check = enterprise_hook("manage_external", array($incident));
                if ($external_check !== ENTERPRISE_NOT_HOOK && !$external_check) {
                    continue;
                } else {
                    //Normal ACL pass if IR for this group or if the user is the incident creator
                    //or if the user is the owner or if the user has workunits
                    $check_acl = enterprise_hook("incidents_check_incident_acl", array($incident));
                    if (!$check_acl) {
                        continue;
                    }
                }
                $inventories = get_inventories_in_incident($incident['id_incidencia'], false);
                if ($filters['id_inventory']) {
                    $found = false;
                    foreach ($inventories as $inventory) {
                        if ($inventory['id'] == $filters['id_inventory']) {
                            $found = true;
                            break;
                        }
                    }
                    if (!$found) {
                        continue;
                    }
                }
                if ($filters['id_company']) {
                    $found = false;
                    $user_creator = $incident['id_creator'];
                    $user_company = get_db_value('id_company', 'tusuario', 'id_usuario', $user_creator);
                    //If company do no match, dismiss incident
                    if ($filters['id_company'] != $user_company) {
                        continue;
                    }
                }
                if ($filters['left_sla']) {
                    $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia']));
                    //If sla do not match, dismiss incident
                    if ($filters['left_sla'] > $percent_sla_incident) {
                        continue;
                    }
                }
                if ($filters['right_sla']) {
                    $percent_sla_incident = format_numeric(get_sla_compliance_single_id($incident['id_incidencia']));
                    //If sla do not match, dismiss incident
                    if ($filters['right_sla'] < $percent_sla_incident) {
                        continue;
                    }
                }
                array_push($result, $incident);
            }
            return $result;
            break;
    }
}
Exemplo n.º 4
0
function form_search_incident($return = false, $filter = false, $ajax = 0)
{
    include_once "functions_user.php";
    global $config;
    $output = '';
    if (!$filter) {
        $inverse_filter = (bool) get_parameter('search_inverse_filter');
        $search_string = (string) get_parameter('search_string');
        $status = (int) get_parameter('search_status', -10);
        $priority = (int) get_parameter('search_priority', -1);
        $resolution = (int) get_parameter('search_resolution', -1);
        $id_group = (int) get_parameter('search_id_group');
        $id_inventory = (int) get_parameter('search_id_inventory');
        $id_company = (int) get_parameter('search_id_company');
        $search_id_user = (string) get_parameter('search_id_user');
        $search_id_incident_type = (int) get_parameter('search_id_incident_type');
        $date_from = (int) get_parameter("search_from_date");
        $date_start = (string) get_parameter("search_first_date");
        $date_end = (string) get_parameter("search_last_date");
        $search_creator = (string) get_parameter('search_id_creator');
        $search_editor = (string) get_parameter('search_editor');
        $search_closed_by = (string) get_parameter('search_closed_by');
        $group_by_project = (bool) get_parameter('search_group_by_project');
        $sla_state = (int) get_parameter('search_sla_state', 0);
        $id_task = (int) get_parameter('search_id_task', 0);
        $left_sla = (int) get_parameter('search_left_sla', 0);
        $right_sla = (int) get_parameter('search_right_sla', 0);
        $show_hierarchy = (bool) get_parameter('search_show_hierarchy');
        $search_medal = get_parameter('search_medals');
        $name = get_parameter('parent_name');
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        foreach ($type_fields as $key => $type_field) {
            $search_type_field[$type_field['id']] = (string) get_parameter('search_type_field_' . $type_field['id']);
        }
    } else {
        $inverse_filter = (bool) $filter['inverse_filter'];
        $search_string = (string) $filter['string'];
        $priority = (int) $filter['priority'];
        $id_group = (int) $filter['id_group'];
        $status = (int) $filter['status'];
        $resolution = (int) $filter['resolution'];
        $id_company = (int) $filter['id_company'];
        $id_inventory = (int) $filter['id_inventory'];
        $search_id_incident_type = (int) $filter['id_incident_type'];
        $search_id_user = (string) $filter['id_user'];
        $date_from = (int) $filter['from_date'];
        $date_start = (string) $filter['first_date'];
        $date_end = (string) $filter['last_date'];
        $search_creator = (string) $filter['id_creator'];
        $search_editor = (string) $filter['editor'];
        $search_closed_by = (string) $filter['closed_by'];
        $group_by_project = (bool) $filter['group_by_project'];
        $sla_state = (int) $filter['sla_state'];
        $id_task = (int) $filter['id_task'];
        $left_sla = (int) $filter['left_sla'];
        $right_sla = (int) $filter['right_sla'];
        $show_hierarchy = (bool) $filter['show_hierarchy'];
        $search_medal = (int) $filter['medals'];
        $name = (string) $filter['parent_name'];
        //This is inventory obj name value !!!
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        if ($type_fields) {
            foreach ($type_fields as $key => $type_field) {
                $search_type_field[$type_field['id']] = (string) $filter['type_field_' . $type_field['id']];
            }
        }
    }
    /* No action is set, so the form will be sent to the current page */
    $table = new stdclass();
    $table->width = "100%";
    $table->class = "search-table-button";
    $table->data = array();
    // Filter text
    $table->data[0][0] = print_input_text('search_string', $search_string, '', 30, 100, true, __('Text filter'));
    // Status
    $available_status = get_indicent_status();
    $available_status[-10] = __("Not closed");
    $table->data[0][1] = print_select($available_status, 'search_status', $status, '', __('Any'), 0, true, false, true, __('Status'));
    // Groups
    $groups = users_get_groups_for_select($config['id_user'], "IW", true, true);
    $table->data[0][2] = print_select($groups, 'search_id_group', $id_group, '', '', '', true, false, false, __('Group'));
    // Check Box
    $table->data[0][3] = print_checkbox_extended('search_show_hierarchy', 1, $show_hierarchy, false, '', '', true, __('Show hierarchy'));
    $table_advanced = new stdclass();
    $table_advanced->width = "100%";
    $table_advanced->class = "search-table-button";
    $params_owner = array();
    $params_owner['input_id'] = 'text-search_id_user';
    $params_owner['input_name'] = 'search_id_user';
    $params_owner['input_value'] = $search_id_user;
    $params_owner['title'] = __('Owner');
    $params_owner['attributes'] = 'style="width: 210px;"';
    $params_owner['return'] = true;
    $table_advanced->data[1][0] = user_print_autocomplete_input($params_owner);
    $params_editor = array();
    $params_editor['input_id'] = 'text-search_editor';
    $params_editor['input_name'] = 'search_editor';
    $params_editor['input_value'] = $search_editor;
    $params_editor['title'] = __('Editor');
    $params_editor['attributes'] = 'style="width: 210px;"';
    $params_editor['return'] = true;
    $table_advanced->data[1][1] = user_print_autocomplete_input($params_editor);
    $params_closed_by = array();
    $params_closed_by['input_id'] = 'text-search_closed_by';
    $params_closed_by['input_name'] = 'search_closed_by';
    $params_closed_by['input_value'] = $search_closed_by;
    $params_closed_by['title'] = __('Closed by');
    $params_closed_by['attributes'] = 'style="width: 210px;"';
    $params_closed_by['return'] = true;
    $table_advanced->data[1][2] = user_print_autocomplete_input($params_closed_by);
    $params_creator = array();
    $params_creator['input_id'] = 'text-search_id_creator';
    $params_creator['input_name'] = 'search_id_creator';
    $params_creator['input_value'] = $search_creator;
    $params_creator['title'] = __('Creator');
    $params_creator['attributes'] = 'style="width: 210px;"';
    $params_creator['return'] = true;
    $table_advanced->data[1][3] = user_print_autocomplete_input($params_creator);
    $table_advanced->data[2][0] = print_select(get_priorities(), 'search_priority', $priority, '', __('Any'), -1, true, false, false, __('Priority'), false);
    $table_advanced->data[2][1] = print_select(get_incident_resolutions(), 'search_resolution', $resolution, '', __('Any'), -1, true, false, false, __('Resolution'), false);
    //$name = $id_inventory ? get_inventory_name ($id_inventory) : '';
    //Parent name
    $table_advanced->data[2][2] = print_input_text_extended("parent_name", $name, "text-parent_name", '', 20, 0, false, "", "class='inventory_obj_search' style='width:165px !important;'", true, false, __('Inventory object'), false, true);
    $table_advanced->data[2][2] .= "&nbsp;&nbsp;" . print_image("images/add.png", true, array("onclick" => "show_inventory_search('','','','','','','','','','', '', '')", "style" => "cursor: pointer"));
    $table_advanced->data[2][2] .= "&nbsp;&nbsp;" . print_image("images/cross.png", true, array("onclick" => "cleanParentInventory()", "style" => "cursor: pointer"));
    $table_advanced->data[2][2] .= print_input_hidden('id_parent', $id_inventory, true);
    $table_advanced->data[2][3] = get_last_date_control($date_from, 'search_from_date', __('Date'), $date_start, 'search_first_date', __('Created from'), $date_end, 'search_last_date', __('Created to'));
    $table_advanced->rowspan[2][3] = 2;
    $table_advanced->cellstyle[2][3] = "vertical-align:top;";
    if (!get_standalone_user($config["id_user"])) {
        $table_advanced->data[4][0] = print_select(get_companies(), 'search_id_company', $id_company, '', __('Any'), 0, true, false, false, __('Company'));
    }
    $table_advanced->data[4][1] = print_select(get_incident_types(), 'search_id_incident_type', $search_id_incident_type, 'javascript:change_type_fields_table(\'' . __('Custom field') . '\');', __('Any'), 0, true, false, false, __('Ticket type'));
    $table_advanced->data[4][3] = print_checkbox_extended('search_group_by_project', 1, $group_by_project, false, '', '', true, __('Group by project/task'));
    $sla_states = array();
    $sla_states[1] = __('SLA is fired');
    $sla_states[2] = __('SLA is not fired');
    $table_advanced->data[5][0] = print_select($sla_states, 'search_sla_state', $sla_state, '', __('Any'), 0, true, false, false, __('SLA'));
    $table_advanced->data[5][1] = combo_task_user_participant($config["id_user"], 0, $id_task, true, __("Task"), 'search_id_task');
    $table_advanced->data[5][2] = "<div>";
    $table_advanced->data[5][2] .= "<div style='display: inline-block;'>" . print_input_text('search_left_sla', $left_sla, '', 8, 0, true, __('SLA > (%)'), false) . "</div>";
    $table_advanced->data[5][2] .= "&nbsp;<div style='display: inline-block;'>" . print_input_text('search_right_sla', $right_sla, '', 8, 0, true, __('SLA < (%)'), false) . "</div>";
    $table_advanced->data[5][2] .= "</div>";
    $medals = array();
    $medals[1] = __('Gold medals');
    $medals[2] = __('Black medals');
    $table_advanced->data[5][3] = print_select($medals, 'search_medals', $search_medal, '', __('Any'), 0, true, false, false, __('Medals'));
    $table_type_fields = new StdClass();
    $table_type_fields->width = "100%";
    $table_type_fields->class = "search-table";
    $table_type_fields->data = array();
    $table_type_fields->align[0] = 'left';
    //Print custom field data
    $column = 0;
    $row = 0;
    if ($type_fields) {
        foreach ($type_fields as $key => $type_field) {
            $data = $search_type_field[$type_field['id']];
            switch ($type_field['type']) {
                case "text":
                    $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
                    break;
                case "combo":
                    $combo_values = explode(",", $type_field['combo_value']);
                    $values = array();
                    foreach ($combo_values as $value) {
                        $values[$value] = $value;
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, '', __('Any'), '', true, false, false, $type_field['label']);
                    break;
                case "linked":
                    $linked_values = explode(",", $type_field['linked_value']);
                    $values = array();
                    foreach ($linked_values as $value) {
                        $value_without_parent = preg_replace("/^.*\\|/", "", $value);
                        $values[$value_without_parent] = $value_without_parent;
                        $has_childs = get_db_all_rows_sql("SELECT * FROM tincident_type_field WHERE parent=" . $type_field['id']);
                        if ($has_childs) {
                            $i = 0;
                            foreach ($has_childs as $child) {
                                if ($i == 0) {
                                    $childs = $child['id'];
                                } else {
                                    $childs .= ',' . $child['id'];
                                }
                                $i++;
                            }
                            $childs = "'" . $childs . "'";
                            $script = 'javascript:change_linked_type_fields_table(' . $childs . ',' . $type_field['id'] . ');';
                        } else {
                            $script = '';
                        }
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, $script, __('Any'), '', true, false, false, $type_field['label']);
                    break;
                case "numeric":
                    $input = print_input_number('search_type_field_' . $type_field['id'], $data, 1, 1000000, '', true, $type_field['label']);
                    break;
                case "date":
                    $input = print_input_date('search_type_field_' . $type_field['id'], $data, '', '', '', true, $type_field['label']);
                    break;
                case "textarea":
                    $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
                    break;
            }
            $table_type_fields->data[$row][$column] = $input;
            if ($column >= 3) {
                $column = 0;
                $row++;
            } else {
                $column++;
            }
        }
    }
    $table_advanced->colspan[6][0] = 4;
    if ($table_type_fields->data) {
        $table_type_fields_html = print_table($table_type_fields, true);
    }
    if (!isset($table_type_fields_html)) {
        $table_type_fields_html = '';
    }
    $table_advanced->data[6][0] = "<div id='table_type_fields'>" . $table_type_fields_html . "</div>";
    $table->colspan['row_advanced'][0] = 5;
    $table->data['row_advanced'][0] = print_container_div('advanced_parameters_incidents_search', __('Advanced filter'), print_table($table_advanced, true), 'closed', true, true);
    //Store serialize filter
    serialize_in_temp($filter, $config["id_user"]);
    $table->colspan['button'][0] = 2;
    $table->colspan['button'][2] = 2;
    $table->data['button'][0] = '</br>';
    $table->data['button'][2] = print_submit_button(__('Filter'), 'search', false, 'class="sub search"', true);
    $table->data['button'][2] .= print_input_hidden('search_inverse_filter', (int) $inverse_filter, true);
    $table->data['button'][2] .= print_submit_button(__('Inverse filter'), 'submit_inverse_filter', false, 'class="sub search"', true);
    $table->data['button'][2] .= print_button(__('Export to CSV'), '', false, 'window.open(\'' . 'include/export_csv.php?export_csv_tickets=1' . '\')', 'class="sub"', true);
    // Inverse filter info
    $output .= '<div id="inverse_filter_info" style="display: ' . ($inverse_filter ? 'block' : 'none') . ';">';
    $output .= ui_print_message(__('Inverse filter enabled'), 'suc', 'style="display:inline;padding-top: 15px;padding-bottom: 15px;"', true, 'h3', false);
    $output .= print_help_tip(__('The result will be the items which doesn\'t match the filters') . '. ' . __('The select controls with \'Any\' or \'All\' selected will be ignored'), true);
    $output .= '<br /><br />';
    $output .= '</div>';
    if ($ajax) {
        $output .= '<form id="search_incident_form" method="post">';
    } else {
        $output .= '<form id="search_incident_form" method="post" onsubmit="incidents_gift();return false">';
    }
    //~ $output .= '<form id="search_incident_form" method="post">';
    $output .= '<div class="divresult_incidents">' . print_table($table, true) . '</div>';
    $output .= '</form>';
    echo "<div class= 'dialog ui-dialog-content' id='search_inventory_window'></div>";
    // WARNING: Important for the inverse filter feature
    // Change the search_inverse_filter value when the form is submitted using the submit_inverse_filter or the search buttons
    // Show or hide the inverse filter info
    $output .= '<script type="text/javascript">';
    $output .= '$(document).ready(function () {';
    $output .= 'var inverseFilterInfo = document.getElementById("inverse_filter_info");';
    $output .= 'var filterForm = document.getElementById("search_incident_form");';
    $output .= 'var filterBtn = filterForm.elements["search"];';
    $output .= 'var inverseFilterBtn = filterForm.elements["submit_inverse_filter"];';
    $output .= 'var inverseFilter = filterForm.elements["search_inverse_filter"];';
    $output .= '$(filterBtn).click(function (e) {';
    $output .= 'inverseFilter.value = 0;';
    $output .= '$(inverseFilterInfo).hide();';
    $output .= '});';
    $output .= '$(inverseFilterBtn).click(function (e) {';
    $output .= 'inverseFilter.value = 1;';
    $output .= '$(inverseFilterInfo).show();';
    $output .= '});';
    $output .= '});';
    $output .= '</script>';
    if ($return) {
        return $output;
    }
    echo $output;
}
Exemplo n.º 5
0
function incidents_search_result($filter, $ajax = false, $return_incidents = false, $print_result_count = false, $no_parents = false, $resolve_names = false, $report_mode = false, $csv_mode = false, $id_ticket = 0)
{
    global $config;
    echo '<div class = "incident_table" id = "incident_table">';
    $params = "";
    foreach ($filter as $key => $value) {
        $params .= "&search_" . $key . "=" . $value;
    }
    if ($filter['closed_by'] == '') {
        $filter['closed_by'] = get_parameter('search_closed_by', '');
    }
    if ($filter['from_date'] == '') {
        $filter['from_date'] = get_parameter('search_from_date', '');
    }
    //Only show incident for last year if there isn't a search by dates
    if (!$filter['first_date'] && !$filter['last_date']) {
        $filter_year = $filter;
        $now = print_mysql_timestamp();
        $year_in_seconds = 3600 * 24 * 365;
        $year_ago_unix = time() - $year_in_seconds;
        $year_ago = date("Y-m-d H:i:s", $year_ago_unix);
        $filter_year['first_date'] = $year_ago;
        $filter_year['last_date'] = $now;
        $count_this_year = filter_incidents($filter_year, true, false, $no_parents, $csv_mode);
        $aux_text = "(" . $count_this_year . ")" . print_help_tip(__("Tickets created last year"), true);
    }
    if (!$report_mode) {
        //Add offset to filter parameters
        $offset = get_parameter("offset");
        $filter["offset"] = $offset;
        // Store the previous limit filter
        if (isset($filter["limit"])) {
            $limit_aux = $filter["limit"];
        } else {
            $limit_aux = 0;
        }
    }
    // Set the limit filter to 0 to retrieve all the tickets for the array pagination
    $filter["limit"] = 0;
    // All the tickets the user sees are retrieved
    $incidents = filter_incidents($filter, false, true, $no_parents, $csv_mode);
    $count = empty($incidents) ? 0 : count($incidents);
    if ($resolve_names) {
        $incidents_aux = array();
        $i = 0;
        foreach ($incidents as $inc) {
            $incidents_aux[$i] = $inc;
            $incidents_aux[$i]['estado'] = incidents_get_incident_status_text($inc['id_incidencia']);
            $incidents_aux[$i]['resolution'] = incidents_get_incident_resolution_text($inc['id_incidencia']);
            $incidents_aux[$i]['prioridad'] = incidents_get_incident_priority_text($inc['id_incidencia']);
            $incidents_aux[$i]['id_grupo'] = incidents_get_incident_group_text($inc['id_incidencia']);
            $incidents_aux[$i]['id_group_creator'] = incidents_get_incident_group_text($inc['id_incidencia']);
            //~ $incidents_aux[$i]['id_incident_type'] = incidents_get_incident_type_text ($inc['id_incidencia']);
            $i++;
        }
        $incidents = $incidents_aux;
    }
    if ($return_incidents) {
        return $incidents;
    }
    if (!$report_mode) {
        // Set the limit filter to its previous value
        $filter["limit"] = $limit_aux;
        $url = "index.php?sec=incidents&sec2=operation/incidents/incident_search" . $params;
        echo "<div class='clear_both'>";
        $incidents = print_array_pagination($incidents, $url, $offset);
        echo "</div>";
    }
    $statuses = get_indicent_status();
    $resolutions = get_incident_resolutions();
    // ORDER BY
    if ($filter['order_by'] && !is_array($filter['order_by'])) {
        $order_by = json_decode(clean_output($filter['order_by']), true);
    } else {
        $order_by = $filter['order_by'];
    }
    if (!$report_mode) {
        if (is_array($order_by) && array_key_exists("id_incidencia", $order_by) && $order_by["id_incidencia"] != "") {
            if ($order_by["id_incidencia"] == "DESC") {
                $id_order_image = "&nbsp;<a href='javascript:changeIncidentOrder(\"id_incidencia\", \"ASC\")'><img src='images/arrow_down_orange.png'></a>";
            } else {
                $id_order_image = "&nbsp;<a href='javascript:changeIncidentOrder(\"id_incidencia\", \"\")'><img src='images/arrow_up_orange.png'></a>";
            }
        } else {
            $id_order_image = "&nbsp;<a href='javascript:changeIncidentOrder(\"id_incidencia\", \"DESC\")'><img src='images/block_orange.png'></a>";
        }
        if (is_array($order_by) && array_key_exists("prioridad", $order_by) && $order_by["prioridad"] != "") {
            if ($order_by["prioridad"] == "DESC") {
                $priority_order_image = "<a href='javascript:changeIncidentOrder(\"prioridad\", \"ASC\")'><img src='images/arrow_down_orange.png'></a>";
            } else {
                $priority_order_image = "<a href='javascript:changeIncidentOrder(\"prioridad\", \"\")'><img src='images/arrow_up_orange.png'></a>";
            }
        } else {
            $priority_order_image = "<a href='javascript:changeIncidentOrder(\"prioridad\", \"DESC\")'><img src='images/block_orange.png'></a>";
        }
    } else {
        $id_order_image = "";
        $priority_order_image = "";
    }
    // ----------------------------------------
    // Here we print the result of the search
    // ----------------------------------------
    echo '<table width="100%" cellpadding="0" cellspacing="0" border="0px" class="listing" id="incident_search_result_table">';
    echo '<thead>';
    echo "<tr>";
    echo "<th>";
    echo print_checkbox('incidentcb-all', "", false, true);
    echo "</th>";
    echo "<th>";
    echo __('ID') . $id_order_image;
    echo "</th>";
    echo "<th>";
    echo __('SLA');
    echo "</th>";
    if ($report_mode) {
        echo "<th>";
        echo __(' % SLA');
        echo "</th>";
    }
    echo "<th>";
    echo __('Ticket');
    echo "</th>";
    echo "<th>";
    echo __('Group') . "/<br /><i>" . __('Company') . "</i>";
    echo "</th>";
    echo "<th>";
    echo __('Status') . "/<br /><i>" . __('Resolution') . "</i>";
    echo "</th>";
    echo "<th>";
    echo __('Prior') . $priority_order_image;
    echo "</th>";
    echo "<th>";
    echo __('Updated') . "/<br /><i>" . __('Started') . "</i>";
    echo "</th>";
    if ($config["show_creator_incident"] == 1) {
        echo "<th>";
    }
    echo __('Creator');
    echo "</th>";
    if ($config["show_owner_incident"] == 1) {
        echo "<th>";
    }
    echo __('Owner');
    echo "</th>";
    echo "</tr>";
    echo '</thead>';
    echo "<tbody>";
    if ($incidents == false) {
        echo '<tr><td colspan="11">' . __('Nothing was found') . '</td></tr>';
    } else {
        foreach ($incidents as $incident) {
            /* We print the rows directly, because it will be used in a sortable
               jQuery table and it only needs the rows */
            if ($incident["estado"] < 3) {
                $tr_status = 'class="red_row"';
            } elseif ($incident["estado"] < 6) {
                $tr_status = 'class="yellow_row"';
            } else {
                $tr_status = 'class="green_row"';
            }
            if ($incident["id_incidencia"] != $id_ticket) {
                echo '<tr ' . $tr_status . ' id="incident-' . $incident['id_incidencia'] . '"';
                echo " style='border-bottom: 1px solid #ccc;' >";
                echo '<td>';
                print_checkbox_extended('incidentcb-' . $incident['id_incidencia'], $incident['id_incidencia'], false, '', '', 'class="cb_incident"');
                echo '</td>';
                //Print incident link if not ajax, if ajax link to js funtion to replace parent
                $link = "index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=" . $incident["id_incidencia"];
                if ($ajax) {
                    $link = "javascript:update_parent('" . $incident["id_incidencia"] . "')";
                }
                echo '<td>';
                if (!$report_mode) {
                    echo '<strong><a href="' . $link . '">#' . $incident['id_incidencia'] . '</a></strong></td>';
                } else {
                    echo '<strong>' . '#' . $incident['id_incidencia'] . '</strong></td>';
                }
                // SLA Fired ??
                if ($incident["affected_sla_id"] != 0) {
                    echo '<td><img src="images/exclamation.png" /></td>';
                } else {
                    echo '<td></td>';
                }
                // % SLA
                if ($report_mode) {
                    echo "<td>";
                    if ($incident["affected_sla_id"] != 0) {
                        echo format_numeric(get_sla_compliance_single_id($incident['id_incidencia']));
                    } else {
                        echo "";
                    }
                    echo "</td>";
                }
                echo '<td>';
                if (!$report_mode) {
                    echo '<strong><a href="' . $link . '">' . ui_print_truncate_text(safe_output($incident['titulo']), 50) . '</a></strong><br>';
                } else {
                    echo '<strong>' . $incident['titulo'] . '</strong><br>';
                }
                echo "<span>";
                echo incidents_get_incident_type_text($incident["id_incidencia"]);
                // Added by slerena 26Ago2013
                $sql = sprintf("SELECT * FROM tincident_type_field WHERE id_incident_type = %d", $incident["id_incident_type"]);
                $config['mysql_result_type'] = MYSQL_ASSOC;
                $type_fields = get_db_all_rows_sql($sql);
                $type_fields_values_text = "";
                if ($type_fields) {
                    foreach ($type_fields as $type_field) {
                        if ($type_field["show_in_list"]) {
                            $field_data = get_db_value_filter("data", "tincident_field_data", array("id_incident" => $incident["id_incidencia"], "id_incident_field" => $type_field["id"]));
                            if ($field_data) {
                                if ($type_field["type"] == "textarea") {
                                    $field_data = "<div style='display: inline-block;' title='{$field_data}'>" . substr($field_data, 0, 15) . "...</div>";
                                }
                                $type_fields_values_text .= " <div title='" . $type_field["label"] . "' style='display: inline-block;'>[" . safe_output($field_data) . "]</div>";
                            }
                        }
                    }
                }
                echo "{$type_fields_values_text}";
                echo '</span></td>';
                echo '<td>' . get_db_value("nombre", "tgrupo", "id_grupo", $incident['id_grupo']);
                if ($config["show_creator_incident"] == 1) {
                    $id_creator_company = get_db_value("id_company", "tusuario", "id_usuario", $incident["id_creator"]);
                    if ($id_creator_company != 0) {
                        $company_name = (string) get_db_value('name', 'tcompany', 'id', $id_creator_company);
                        echo " /<br/> <span>{$company_name}</span>";
                    }
                }
                echo '</td>';
                $resolution = isset($resolutions[$incident['resolution']]) ? $resolutions[$incident['resolution']] : __('None');
                $gold = "";
                $black = "";
                if ($incident['gold_medals']) {
                    $gold = print_image('images/insignia_dorada.png', true) . "(" . $incident['gold_medals'] . ")";
                }
                if ($incident['black_medals']) {
                    $black = print_image('images/insignia_gris.png', true) . "(" . $incident['black_medals'] . ")";
                }
                echo '<td><strong>' . $statuses[$incident['estado']] . '</strong><br /><em>' . $resolution . '</em>' . $gold . $black . '</td>';
                // priority
                echo '<td>';
                print_priority_flag_image($incident['prioridad']);
                $last_wu = get_incident_lastworkunit($incident["id_incidencia"]);
                if ($last_wu["id_user"] == $incident["id_creator"]) {
                    echo "<img src='images/comment.gif' title='" . $last_wu["id_user"] . "'>";
                }
                echo '</td>';
                echo '<td>' . human_time_comparation($incident["actualizacion"]);
                // Show only if it's different
                if ($incident["inicio"] != $incident["actualizacion"]) {
                    echo " / <br /> [" . human_time_comparation($incident["inicio"]);
                    echo "]";
                }
                //echo "<br>";
                echo '<span style="display:inline-table;">';
                /*
                if (isset($config["show_user_name"]) && ($config["show_user_name"])) {
                	$updated_by = get_db_value('nombre_real', 'tusuario', 'id_usuario', $last_wu["id_user"]);
                }
                else {
                	$updated_by = $last_wu["id_user"];
                }
                echo "&nbsp;$updated_by";
                */
                echo "</span>";
                echo '</td>';
                if ($config["show_creator_incident"] == 1) {
                    echo "<td>";
                    if (isset($config["show_user_name"]) && $config["show_user_name"]) {
                        $incident_creator = get_db_value('nombre_real', 'tusuario', 'id_usuario', $incident["id_creator"]);
                    } else {
                        $incident_creator = $incident["id_creator"];
                    }
                    //~ echo substr($incident_creator,0,12);
                    echo "&nbsp;{$incident_creator}";
                    echo "</td>";
                }
                if ($config["show_owner_incident"] == 1) {
                    echo "<td>";
                    if (isset($config["show_user_name"]) && $config["show_user_name"]) {
                        $incident_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $incident["id_usuario"]);
                    } else {
                        $incident_owner = $incident["id_usuario"];
                    }
                    echo "&nbsp;{$incident_owner}";
                    echo "</td>";
                }
                echo '</tr>';
            }
        }
    }
    echo "</tbody>";
    echo "</table>";
    if (!$report_mode) {
        pagination($count, $url, $offset, false, $aux_text);
    }
    if ($print_result_count) {
        echo "<h5>" . $count . __(" ticket(s) found") . "</h5>";
    }
    echo "</div>";
}