$rows = get_db_all_rows_sql ("SELECT id, name FROM tincident_type ORDER BY name ASC"); $search_by_type = "<table>"; if (!$rows) { $search_by_type .="<tr>"; $search_by_type .="<td>"; $search_by_type .="<em>".__("There aren't ticket types defined")."</em>"; $search_by_type .="</td>"; $search_by_type .="</tr>"; } else { $count = 0; $rows = get_incident_types(); foreach ($rows as $id => $name) { if ($count % 2 == 0) { $search_by_type .= "<tr>"; } if ($id != -1) { $incidents = get_incidents("id_incident_type = ".$id." AND estado <> 7", true); } else { //Without type means type 0 and NULL $incidents = get_incidents("(id_incident_type = 0 OR id_incident_type IS NULL) AND estado <> 7", true); } $search_by_type .= "<td>";
} else { $table->data[0][0] = print_label(__('Title'), '', '', true, $titulo); } //Get group if was not defined if ($id_grupo == 0) { $id_grupo_incident = get_db_value("id_grupo", "tusuario_perfil", "id_usuario", $config['id_user']); //If no group assigned use ALL by default if (!$id_grupo_incident) { $id_grupo_incident = 1; } } else { $id_grupo_incident = $id_grupo; } $groups = users_get_groups_for_select($config['id_user'], "IW", false, true); $table->data[0][1] = print_select($groups, "grupo_form", $id_grupo_incident, '', '', 0, true, false, false, __('Group'), $blocked_incident) . "<div id='group_spinner'></div>"; $types = get_incident_types(true, $config['required_ticket_type']); $table->data[0][2] = print_label(__('Ticket type'), '', '', true); //Disabled incident type if any, type changes not allowed if ($id <= 0 || $config["incident_type_change"] == 1 || dame_admin($config['id_user'])) { $disabled_itype = false; } else { $disabled_itype = true; } if ($disabled_itype || $blocked_incident) { $disabled_itype = true; } if ($config['required_ticket_type']) { $select = ''; } else { $select = 'select'; }
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; }
// LOAD GLOBAL VARS global $config; // CHECK LOGIN AND ACLs check_login(); if (!give_acl($config['id_user'], 0, "IR")) { audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access ticket viewer"); require "general/noaccess.php"; exit; } // GET THE FIRST KNOWN GROUP OF THE USER $user_groups = get_user_groups($config['id_user']); $group_id = reset(array_keys($user_groups)); // GET PRIORITIES $priorities = get_priorities(); // GET INCIDENT TYPES $types = get_incident_types(); echo "<h1>" . __('CREATE TICKET') . "</h1>"; echo "<div id=msg-str></div>"; // NEW INCIDENT FORM echo "<div id='form_file'>"; $table->width = '98%'; $table->class = 'search-table'; $table->id = "incident-editor"; $table->style = array(); $table->data = array(); $table->colspan = array(); $table->colspan[0][0] = 2; $table->colspan[2][0] = 2; $table->data[0][0] = print_input_text('title', '', '', 100, 0, true, __('Title')); $table->data[1][0] = print_select($priorities, 'priority_form', 2, '', '', '', true, false, false, __('Priority')); $table->data[1][1] = print_select($types, 'id_incident_type', '', 'javascript: show_incident_type_fields(1);', 'Select', '', true, 0, true, __('Ticket type'));
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] .= " " . print_image("images/add.png", true, array("onclick" => "show_inventory_search('','','','','','','','','','', '', '')", "style" => "cursor: pointer")); $table_advanced->data[2][2] .= " " . 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] .= " <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; }
public function getIncidentSimpleForm($action = "index.php?page=incident", $method = "POST") { $ui = Ui::getInstance(); $options = array('id' => 'form-incident', 'action' => $action, 'method' => $method, 'enctype' => 'multipart/form-data', 'data-ajax' => 'false'); $ui->beginForm($options); // Title $options = array('name' => 'title', 'label' => __('Title'), 'value' => $this->title, 'placeholder' => __('Title')); $ui->formAddInputText($options); // Priority $options = array('name' => 'priority', 'title' => __('Priority'), 'label' => __('Priority'), 'items' => get_priorities(), 'selected' => $this->priority); $ui->formAddSelectBox($options); // Type $types = array(); $types = get_incident_types(); array_unshift($types, __('None')); $options = array('name' => 'id_incident_type', 'title' => __('Type'), 'label' => __('Type'), 'items' => $types, 'selected' => $this->id_incident_type); $ui->formAddSelectBox($options); $ui->formAddHtml("<div id='type_fields'></div>"); $ui->formAddHtml("<script type='text/javascript' src='include/javascript/functions_incidents.mobile.js'></script>"); $ui->formAddHtml("<script type='text/javascript'>\n\t\t\t\t\t\t\t \$(document).ready (function () {\n\t\t\t\t\t\t\t\t \$('#select-id_incident_type').on('change', function () {\n\t\t\t\t\t\t\t\t\t showIncidentTypeFields('#type_fields');\n\t\t\t\t\t\t\t\t });\n\t\t\t\t\t\t\t });\n\t\t\t\t\t\t </script>"); // Description $options = array('name' => 'description', 'label' => __('Description'), 'value' => $this->description); $ui->formAddHtml($ui->getTextarea($options)); $ui->contentBeginCollapsible(__('Optional file')); // File $options = array('type' => 'file', 'name' => 'file', 'label' => __('File')); $file_inputs = $ui->getInput($options); // Description $options = array('name' => 'description_file', 'label' => __('File description'), 'value' => $this->description_file); $file_inputs .= $ui->getTextarea($options); $ui->contentCollapsibleAddItem($file_inputs); $collapsible_file = $ui->getEndCollapsible("collapsible-form", "c"); $ui->formAddHtml($collapsible_file); // Hidden operation (insert or update+id) if ($this->id_incident <= 0) { $options = array('type' => 'hidden', 'name' => 'operation', 'value' => 'insert_incident'); $ui->formAddInput($options); // Submit button $options = array('text' => __('Add'), 'data-icon' => 'plus'); $ui->formAddSubmitButton($options); } else { $options = array('type' => 'hidden', 'name' => 'operation', 'value' => 'update_incident'); $ui->formAddInput($options); $options = array('type' => 'hidden', 'name' => 'id_incident', 'value' => $this->id_incident); $ui->formAddInput($options); // Submit button $options = array('text' => __('Update'), 'data-icon' => 'refresh'); $ui->formAddSubmitButton($options); } return $ui->getEndForm(); }