$table_search->data[3][0] .= print_input_hidden ('sort_field', $params['sort_field_num'], true, false, 'sort_field'); $table_search->data[3][0] .= print_input_hidden ('sort_mode', $params['sort_mode'], true, false, 'sort_mode'); //offset pagination hidden if(!isset($params['offset'])){ $params['offset'] = ''; } $table_search->data[3][0] .= print_input_hidden ('offset', $params['offset'], true, false, 'offset'); //mode: list, tree, pure $table_search->data[3][0] .= print_input_hidden ('mode', $params['mode'], true, false, 'mode'); //csv querys $filter["query"] = $sql_search; $filter["query_pag"] = $sql_search_pagination; serialize_in_temp($filter, $config["id_user"]); //tree_search_submit() $table_search->data[3][1] = print_button(__('Export to CSV'), '', false, 'tree_search_submit(); window.open(\'' . 'include/export_csv.php?export_csv_inventory=1'.'\');', 'class="sub csv"', true); //button $table_search->data[3][2] = print_submit_button (__('Search'), 'search', false, 'class="sub search"', true); $search_other .= print_table($table_search, true); $search_other .= '</div>'; print_container_div("inventory_form",__("Inventory form search"),$search_other, 'open', false, false); echo '</form>'; } $write_permission = enterprise_hook ('inventory_check_acl', array ($config['id_user'], $id, true));
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; }
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, $others_str = "other", $homedir = "", $water_mark = "", $font = '', $font_size = '', $ttl = 1) { // This library allows only 8 colors $max_values = 8; // Process data and decode it from HTML encoding $data_temp = array(); foreach ($chart_data as $key => $value) { $data_temp[safe_output($key)] = safe_output($value); } $chart_data = $data_temp; if (count($chart_data) > $max_values) { $chart_data_trunc = array(); $n = 1; foreach ($chart_data as $key => $value) { if ($n < $max_values) { $chart_data_trunc[$key] = $value; } else { if (!isset($chart_data_trunc[$others_str])) { $chart_data_trunc[$others_str] = 0; } $chart_data_trunc[$others_str] += $value; } $n++; } $chart_data = $chart_data_trunc; } if ($flash_chart) { switch ($graph_type) { case "2d": return fs_2d_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height); break; case "3d": return fs_3d_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height); break; } } else { $graph = array(); $graph['data'] = $chart_data; $graph['width'] = $width; $graph['height'] = $height; $graph['water_mark'] = $water_mark; $graph['font'] = $font; $graph['font_size'] = $font_size; $id_graph = serialize_in_temp($graph, null, $ttl); switch ($graph_type) { case "2d": return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie2d&ttl=" . $ttl . "&id_graph=" . $id_graph . "'>"; break; case "3d": return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie3d&ttl=" . $ttl . "&id_graph=" . $id_graph . "'>"; break; } } }
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; }
function inventories_show_list2($sql_search, $sql_count, $params = '', $block_size, $modal = 0, $count_object_custom_fields = 1, $sql_search_pagination) { global $config; $is_enterprise = false; if (file_exists("enterprise/include/functions_inventory.php")) { require_once "enterprise/include/functions_inventory.php"; $is_enterprise = true; } $write_permission = enterprise_hook('inventory_check_acl', array($config['id_user'], '', true)); //csv querys $filter["query"] = $sql_search; $filter["query_pag"] = $sql_search_pagination; serialize_in_temp($filter, $config["id_user"]); $params['mode'] = 'list'; if (!$sql_search) { $sql_search = "SELECT * FROM tinventory"; } $pure = get_parameter("pure"); if ($pure) { $block_limit = 5000; } else { $block_limit = $block_size; } $offset = get_parameter("offset", 0); if ($count_object_custom_fields == 0) { $sql_search .= " LIMIT " . $block_limit; $sql_search .= " OFFSET {$offset}"; $sql_search_pagination .= " LIMIT " . $block_limit; } else { $sql_search_pagination .= " LIMIT " . $block_limit; } $sql_search_pagination .= " OFFSET {$offset}"; $config['mysql_result_type'] = MYSQL_ASSOC; $count_inv_d = get_db_all_rows_sql($sql_count); $count_inv = count($count_inv_d); $inventories_aux = get_db_all_rows_sql($sql_search); $inventories_aux_pagination = get_db_all_rows_sql($sql_search_pagination); $i = 0; $header = array(); if (is_array($inventories_aux_pagination) || is_object($inventories_aux_pagination)) { foreach ($inventories_aux_pagination[0] as $key => $value) { $header[$key] = 1; } if (is_array($inventories_aux_pagination) || is_object($inventories_aux_pagination)) { foreach ($inventories_aux_pagination as $key => $value) { unset($inventories_aux_pagination[$i]['label'], $inventories_aux_pagination[$i]['data']); if (is_array($inventories_aux) || is_object($inventories_aux)) { foreach ($inventories_aux as $k => $v) { if (isset($v['label'])) { $header[$v['label']] = 1; if ($value['id'] == $v['id']) { $inventories_aux_pagination[$i][$v['label']] = $v['data']; } } } $i++; } } } } //deleted label and data unset($header['label'], $header['data'], $header['']); if ($is_enterprise) { $inventories = inventory_get_user_inventories($config['id_user'], $inventories_aux_pagination); } else { $inventories = $inventories_aux_pagination; } //print table if (count($header) == 0) { echo ui_print_error_message(__("Empty inventory"), '', true, 'h3', true); } else { $table = new stdClass(); $table->id = 'inventory_list'; $table->class = 'listing'; $table->width = '100%'; $table->data = array(); $table->head = array(); $table->colspan = array(); //thead $i = 10; foreach ($header as $key => $inventory) { switch ($key) { case 'id': $table->head[0] = __('Id'); break; case 'name': $table->head[1] = __('Name'); break; case 'owner': $table->head[2] = __('Owner'); break; case 'id_parent': $table->head[3] = __("Parent object"); break; case 'id_object_type': $table->head[4] = __('Object type'); break; case 'id_manufacturer': $table->head[5] = __('Manufacturer'); break; case 'id_contract': $table->head[6] = __('Contract'); break; case 'status': $table->head[7] = __('Status'); break; case 'receipt_date': $table->head[8] = __('Receipt date'); break; case 'issue_date': $table->head[9] = __('Issue date'); break; default: $table->head[$i] = $key; $i++; break; } } //thead icon delete and checkbox delete all if (!$pure) { if (!$modal) { $table->head[$i] = __('Actions'); if ($write_permission) { $i = $i + 1; $table->head[$i] = print_checkbox('inventorycb-all', "", false, true); } } } //tbody $idx = 0; foreach ($inventories as $key => $inventory) { $i = 10; foreach ($header as $k => $headervalue) { if ($modal) { $url = "javascript:loadInventory(" . $inventory['id'] . ");"; } else { $url = 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id']; } switch ($k) { case 'id': $data[0] = "<a href=" . $url . ">" . $inventory['id'] . "</a>"; break; case 'name': $data[1] = "<a href=" . $url . ">" . $inventory['name'] . '</a>'; break; case 'owner': if ($inventory['owner'] != '') { $name_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $inventory['owner']); } else { $name_owner = '--'; } $data[2] = "<a href=" . 'index.php?sec=users&sec2=operation/users/user_edit&id=' . $inventory['owner'] . ">" . $name_owner . '</a>'; break; case 'id_parent': if ($inventory['id_parent'] != 0) { $name_parent = get_db_value('name', 'tinventory', 'id', $inventory['id_parent']); $data[3] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/inventory_detail&id=' . $inventory['id_parent'] . ">" . $name_parent . '</a>'; } else { $name_parent = '--'; $data[3] = $name_parent; } break; case 'id_object_type': if ($inventory['id_object_type'] != 0) { $name_object = get_db_value('name', 'tobject_type', 'id', $inventory['id_object_type']); $data[4] = "<a href=" . 'index.php?sec=inventory&sec2=operation/inventories/manage_objects&id=' . $inventory['id_object_type'] . ">" . $name_object . '</a>'; } else { $name_object = '--'; $data[4] = $name_object; } break; case 'id_manufacturer': if ($inventory['id_manufacturer'] != 0) { $name_manufacturer = get_db_value('name', 'tmanufacturer', 'id', $inventory['id_manufacturer']); $data[5] = "<a href=" . 'index.php?sec=inventory&sec2=operation/manufacturers/manufacturer_detail&id=' . $inventory['id_manufacturer'] . ">" . $name_manufacturer . '</a>'; } else { $name_manufacturer = '--'; $data[5] = $name_manufacturer; } break; case 'id_contract': if ($inventory['id_contract'] != 0) { $name_contract = get_db_value('name', 'tcontract', 'id', $inventory['id_contract']); $data[6] = "<a href=" . 'index.php?sec=customers&sec2=operation/contracts/contract_detail&id_contract=' . $inventory['id_contract'] . ">" . $name_contract . '</a>'; } else { $name_contract = '--'; $data[6] = $name_contract; } break; case 'status': if ($inventory['status'] != "") { $data[7] = __($inventory['status']); } else { $status_none = '--'; $data[7] = $status_none; } break; case 'receipt_date': if ($inventory['receipt_date'] != "") { $data[8] = $inventory['receipt_date']; } else { $receipt_date = '--'; $data[8] = $receipt_date; } break; case 'issue_date': if ($inventory['issue_date'] != "0000-00-00") { $data[9] = $inventory['issue_date']; } else { $issue_date = '--'; $data[9] = $issue_date; } break; default: if ($inventory[$k] != "") { $data[$i] = $inventory[$k]; $i++; } else { $inventory_null = '--'; $data[$i] = $inventory_null; $i++; } break; } } //tbody icon delete and checkbox delete all if (!$pure) { if (!$modal) { if ($write_permission) { //$data[$i] = '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory&quick_delete='.$inventory["id"].'¶ms='.$params.'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;"><img src="images/cross.png"></a>'; $data[$i] = '<a href="javascript: delete_object_inventory(' . $inventory["id"] . ')" onClick="if (!confirm(\'' . __('Are you sure delete inventory object ') . $inventory["id"] . '?\')) return false;"><img src="images/cross.png"></a>'; } } } if (!$pure) { if (!$modal) { if ($write_permission) { $i = $i + 1; $data[$i] = print_checkbox_extended('inventorycb-' . $inventory['id'], $inventory['id'], false, '', '', 'class="cb_inventory"', true); } } } $table->rowclass[$idx] = 'inventory_info_' . $inventory["id"]; $idx++; array_push($table->data, $data); } echo '<div id= "inventory_only_table">'; $count = $count_inv; $params = json_encode($params); $params = base64_encode($params); $url_pag = "index.php?sec=inventory&sec2=operation/inventories/inventory¶ms=" . $params; $offset = get_parameter("offset"); if (!$pure) { pagination($count, $url_pag, $offset, false, '', $block_size); } print_table($table); if (!$pure) { pagination($count, $url_pag, $offset, true, '', $block_size); } echo '</div>'; if (!$pure) { if (!$modal) { if ($write_permission) { echo '<div class="button-form">'; echo print_button(__('Delete All'), '', false, 'javascript: delete_massive_inventory()', 'class="sub"', true); echo '</div>'; } } } } }