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] .= " <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; }
$output .= "<strong>".__('Priority').': </strong>'.print_priority_flag_image ($filter['priority'], true); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Group').': </strong>'.get_db_value ('nombre', 'tgrupo', 'id_grupo', $filter['id_group']); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Product').': </strong>'.get_db_value ('name', 'tkb_product', 'id', $filter['id_product']); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Company').': </strong>'.get_db_value ('name', 'tinventory', 'id', $filter['id_company']); $output .= "</td>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td>"; $output .= "<strong>".__('Inventory').': </strong>'.get_inventory_name ($filter['id_inventory']); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Serial number').': </strong>'.$filter['serial_number']; $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Building').': </strong>'.get_db_value ('name', 'tbuilding', 'id', $filter['id_building']); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('User').': </strong>'.$filter['id_user']; $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('Ticket type').': </strong>'.get_db_value ('name', 'tincident_type', 'id', $filter['id_incident_type']); $output .= "</td>"; $output .= "<td>"; $output .= "<strong>".__('From').': </strong>'.$filter['first_date'];
if ($id) { $group = get_db_row('tgrupo', 'id_grupo', $id); if ($group) { $name = $group['nombre']; $icon = $group['icon']; $id_user_default = $group['id_user_default']; $banner = $group['banner']; $parent = $group['parent']; $soft_limit = $group["soft_limit"]; $hard_limit = $group["hard_limit"]; $enforce_soft_limit = (bool) $group["enforce_soft_limit"]; $forced_email = (bool) $group['forced_email']; $id_sla = $group["id_sla"]; $id_user = get_db_value('id_user_default', 'tgrupo', 'id_grupo', $id); $id_inventory = $group["id_inventory_default"]; $inventory_name = get_inventory_name($group["id_inventory_default"]); $autocreate_user = $group["autocreate_user"]; $grant_access = $group["grant_access"]; $send_welcome = $group["send_welcome"]; $default_company = $group["default_company"]; $welcome_email = $group["welcome_email"]; $email_queue = $group["email_queue"]; $default_profile = $group["default_profile"]; $user_level = $group["nivel"]; $incident_type = $group["id_incident_type"]; $email_from = $group["email_from"]; $email_group = $group["email_group"]; //Inventory == zero is an empty string if ($id_inventory == 0) { $id_inventory = ""; }
$table->data[0][1] = user_print_autocomplete_input($params_assigned); } else { $table->data[0][1] = print_label(__('Owner'), '', '', true, $owner); } if ($write_permission || !$id) { $table->data[0][2] = print_checkbox_extended('public', 1, $public, false, '', '', true, __('Public')); } else { $table->data[0][2] = print_checkbox_extended('public', 1, $public, true, '', '', true, __('Public')); } if ($write_permission || !$id) { $parent_name = $id_parent ? get_inventory_name($id_parent) : __("None"); $table->data[1][0] = print_input_text_extended("parent_name", $parent_name, "text-parent_name", '', 20, 0, false, "show_inventory_search('','','','','','','','','','', '', '')", "class='inventory_obj_search'", true, false, __('Parent object')); $table->data[1][0] .= print_image("images/cross.png", true, array("onclick" => "cleanParentInventory()", "style" => "cursor: pointer")); $table->data[1][0] .= print_input_hidden('id_parent', $id_parent, true); } else { $parent_name = $id_parent ? get_inventory_name($id_parent) : __('Not set'); $table->data[1][0] = print_label(__('Parent object'), '', '', true, $parent_name); if ($id_parent) { $table->data[1][0] .= '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $id_parent . '"><img src="images/go.png" /></a>'; } } $contracts = get_contracts(); $manufacturers = get_manufacturers(); if ($write_permission || !$id) { $table->data[1][1] = print_select($contracts, 'id_contract', $id_contract, '', __('None'), 0, true, false, false, __('Contract')); $table->data[1][2] = print_select($manufacturers, 'id_manufacturer', $id_manufacturer, '', __('None'), 0, true, false, false, __('Manufacturer')); } else { $contract = isset($contracts[$id_contract]) ? $contracts[$id_contract] : __('Not set'); $manufacturer = isset($manufacturers[$id_manufacturer]) ? $manufacturers[$id_manufacturer] : __('Not set'); $table->data[1][1] = print_label(__('Contract'), '', '', true, $contract); $table->data[1][2] = print_label(__('Manufacturer'), '', '', true, $manufacturer);