diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 5082fd6975..d9843f9860 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -1,17 +1,32 @@ 0, 1, 0)) AS alerts_module_count, - SUM(IF($condition_warning, 1, 0)) AS warning_module_count, - SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count, - SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count, - SUM(IF($condition_critical, 1, 0)) AS critical_module_count, - SUM(IF($condition_normal, 1, 0)) AS normal_module_count, - COUNT(tae.id_agente_modulo) AS total_count, - tmg.id_mg, - tmg.name as n, - tg.id_grupo - FROM ( - SELECT tam.id_agente_modulo, - tam.id_module_group, - ta.id_grupo AS g, - tae.estado, - SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired - FROM tagente_modulo tam - LEFT JOIN talert_template_modules tatm - ON tatm.id_agent_module = tam.id_agente_modulo - AND tatm.times_fired = 1 - LEFT JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - INNER JOIN tagente ta - ON ta.id_agente = tam.id_agente - WHERE ta.disabled = 0 - AND tam.disabled = 0 - AND tam.delete_pending = 0 - AND ta.id_grupo IN ($ids_group) - GROUP BY tam.id_agente_modulo - UNION ALL - SELECT tam.id_agente_modulo, - tam.id_module_group, - tasg.id_group AS g, - tae.estado, - SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired - FROM tagente_modulo tam - LEFT JOIN talert_template_modules tatm - ON tatm.id_agent_module = tam.id_agente_modulo - AND tatm.times_fired = 1 - LEFT JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - INNER JOIN tagente ta - ON ta.id_agente = tam.id_agente - INNER JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND tam.disabled = 0 - AND tam.delete_pending = 0 - AND tasg.id_group IN ($ids_group) - GROUP BY tam.id_agente_modulo, tasg.id_group - ) AS tae - RIGHT JOIN tgrupo tg - ON tg.id_grupo = tae.g - INNER JOIN ( - SELECT * FROM tmodule_group - UNION ALL - SELECT 0 AS 'id_mg', 'Nothing' AS 'name' - ) AS tmg - ON tae.id_module_group = tmg.id_mg - GROUP BY tae.g, tmg.id_mg"; + $sql = sprintf( + "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count, + SUM(IF(%s, 1, 0)) AS warning_module_count, + SUM(IF(%s, 1, 0)) AS unknown_module_count, + SUM(IF(%s, 1, 0)) AS notInit_module_count, + SUM(IF(%s, 1, 0)) AS critical_module_count, + SUM(IF(%s, 1, 0)) AS normal_module_count, + COUNT(tae.id_agente_modulo) AS total_count, + tmg.id_mg, + tmg.name as n, + tg.id_grupo + FROM ( + SELECT tam.id_agente_modulo, + tam.id_module_group, + ta.id_grupo AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND ta.id_grupo IN (%s) + GROUP BY tam.id_agente_modulo + UNION ALL + SELECT tam.id_agente_modulo, + tam.id_module_group, + tasg.id_group AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + INNER JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND tasg.id_group IN (%s) + GROUP BY tam.id_agente_modulo, tasg.id_group + ) AS tae + RIGHT JOIN tgrupo tg + ON tg.id_grupo = tae.g + INNER JOIN ( + SELECT * FROM tmodule_group + UNION ALL + SELECT 0 AS 'id_mg', 'Nothing' AS 'name' + ) AS tmg + ON tae.id_module_group = tmg.id_mg + GROUP BY tae.g, tmg.id_mg", + $condition_warning, + $condition_unknown, + $condition_not_init, + $condition_critical, + $condition_normal, + $ids_group, + $ids_group + ); $array_data_prev = db_get_all_rows_sql($sql); @@ -220,9 +253,21 @@ function mainModuleGroups() echo ''; echo ''; + $cell_style = ' + min-width: 60px; + width: 100%; + margin: 0; + overflow:hidden; + text-align: center; + padding: 5px; + padding-bottom:10px; + font-size: 18px; + text-align: center; + '; + if (true) { $table = new StdClass(); - $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; + $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; min-width: 230px;'; $table->width = '100%'; $head[0] = __('Groups'); @@ -264,12 +309,12 @@ function mainModuleGroups() // Blue when the cell for this module group and all modules have not init value. } - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= ""; $data[$i][$j] .= $array_data[$key][$k]['total_count']; $data[$i][$j] .= '
'; } else { - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= 0; $data[$i][$j] .= '
'; } @@ -278,7 +323,7 @@ function mainModuleGroups() } } else { foreach ($value['gm'] as $k => $v) { - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= 0; $data[$i][$j] .= '
'; $j++; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 88b84a2573..7c6a3ab03b 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -176,7 +176,7 @@ if ($disk_conf_delete) { @unlink($filename['conf']); } -echo '
'; +echo ''; // Custom ID. $custom_id_div = '
'; @@ -674,7 +674,7 @@ if (enterprise_installed()) { '', '', // Autocomplete. - 'off' + 'new-password' ).'
'; } else { $table_adv_url = '

'.__('Url address').':

'; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b63dfe6454..411267aa2c 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -192,7 +192,7 @@ function events_get_events_no_grouped( /** * Return all events matching sql_post grouped. * - * @param [type] $sql_post Sql_post. + * @param string $sql_post Sql_post. * @param integer $offset Offset. * @param integer $pagination Pagination. * @param boolean $meta Meta. @@ -213,7 +213,7 @@ function events_get_events_grouped( $total=false, $history_db=false, $order='down', - $sort_field='timestamp' + $sort_field='utimestamp' ) { global $config; @@ -228,30 +228,48 @@ function events_get_events_grouped( db_process_sql('SET group_concat_max_len = 9999999'); $event_lj = events_get_secondary_groups_left_join($table); if ($total) { - $sql = "SELECT COUNT(*) FROM (SELECT id_evento - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t'; + $sql = sprintf( + 'SELECT COUNT(*) FROM (SELECT id_evento + FROM %s te %s + WHERE 1=1 %s + GROUP BY estado, evento, id_agente, id_agentmodule %s) AS t ', + $table, + $event_lj, + $sql_post, + $groupby_extra + ); } else { - $sql = "SELECT *, MAX(id_evento) AS id_evento, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, - GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, + $sql = sprintf( + 'SELECT *, MAX(id_evento) AS id_evento, + GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
") AS user_comment, + GROUP_CONCAT(DISTINCT id_evento SEPARATOR ",") AS similar_ids, COUNT(id_evento) AS event_rep, MAX(utimestamp) AS timestamp_rep, MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, - (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra; + (SELECT owner_user FROM %s WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM %s WHERE id_evento = MAX(te.id_evento)) id_usuario, + (SELECT id_agente FROM %s WHERE id_evento = MAX(te.id_evento)) id_agente, + (SELECT criticity FROM %s WHERE id_evento = MAX(te.id_evento)) AS criticity, + (SELECT ack_utimestamp FROM %s WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, + (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name, + (SELECT alias FROM tagente WHERE id_agente = te.id_agente) agent_name + FROM %s te %s + WHERE 1=1 %s + GROUP BY estado, evento, id_agente, id_agentmodule %s ', + $table, + $table, + $table, + $table, + $table, + $table, + $event_lj, + $sql_post, + $groupby_extra + ); $sql .= ' '.events_get_sql_order($sort_field, $order, 2); $sql .= ' LIMIT '.$offset.','.$pagination; } - // Extract the events by filter (or not) from db + // Extract the events by filter (or not) from db. $events = db_get_all_rows_sql($sql, $history_db); if ($total) { diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index f9e5b402f7..54cfced997 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2539,13 +2539,13 @@ function graph_agent_status($id_agent=false, $width=300, $height=200, $return=fa } // $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN); - $colors[__('Critical')] = COL_CRITICAL; - $colors[__('Warning')] = COL_WARNING; - $colors[__('Normal')] = COL_NORMAL; - $colors[__('Unknown')] = COL_UNKNOWN; + $colors['Critical'] = COL_CRITICAL; + $colors['Warning'] = COL_WARNING; + $colors['Normal'] = COL_NORMAL; + $colors['Unknown'] = COL_UNKNOWN; if ($show_not_init) { - $colors[__('Not init')] = COL_NOTINIT; + $colors['Not init'] = COL_NOTINIT; } if (array_sum($data) == 0) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index c658a55e31..c8b893c091 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -327,7 +327,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals if ($user_access_node && check_acl($config['id_user'], $id_group, 'AW')) { // Actions table - echo '
'; + echo '
'; echo ''; html_print_submit_button(__('Go to module edition'), 'upd_button', false, 'class="sub config"'); echo ''; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index cdcc5abbbe..17519d8eed 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1785,47 +1785,6 @@ function ui_process_page_head($string, $bitfield) * End load CSS */ - /* - * Load JS - */ - - if (empty($config['js'])) { - $config['js'] = []; - // If it's empty, false or not init set array to empty just in case. - } - - // Pandora specific JavaScript should go first. - $config['js'] = array_merge(['pandora' => 'include/javascript/pandora.js'], $config['js']); - // Load base64 javascript library. - $config['js']['base64'] = 'include/javascript/encode_decode_base64.js'; - // Load webchat javascript library. - $config['js']['webchat'] = 'include/javascript/webchat.js'; - // Load qrcode library. - $config['js']['qrcode'] = 'include/javascript/qrcode.js'; - // Load intro.js library (for bubbles and clippy). - $config['js']['intro'] = 'include/javascript/intro.js'; - $config['js']['clippy'] = 'include/javascript/clippy.js'; - // Load Underscore.js library. - $config['js']['underscore'] = 'include/javascript/underscore-min.js'; - - // Load other javascript. - // We can't load empty. - $loaded = ['']; - foreach ($config['js'] as $name => $filename) { - if (in_array($name, $loaded)) { - continue; - } - - array_push($loaded, $name); - - $url_js = ui_get_full_url($filename); - $output .= ''."\n\t"; - } - - /* - * End load JS - */ - /* * Load jQuery */ @@ -1883,6 +1842,47 @@ function ui_process_page_head($string, $bitfield) * End load JQuery */ + /* + * Load JS + */ + + if (empty($config['js'])) { + $config['js'] = []; + // If it's empty, false or not init set array to empty just in case. + } + + // Pandora specific JavaScript should go first. + $config['js'] = array_merge(['pandora' => 'include/javascript/pandora.js'], $config['js']); + // Load base64 javascript library. + $config['js']['base64'] = 'include/javascript/encode_decode_base64.js'; + // Load webchat javascript library. + $config['js']['webchat'] = 'include/javascript/webchat.js'; + // Load qrcode library. + $config['js']['qrcode'] = 'include/javascript/qrcode.js'; + // Load intro.js library (for bubbles and clippy). + $config['js']['intro'] = 'include/javascript/intro.js'; + $config['js']['clippy'] = 'include/javascript/clippy.js'; + // Load Underscore.js library. + $config['js']['underscore'] = 'include/javascript/underscore-min.js'; + + // Load other javascript. + // We can't load empty. + $loaded = ['']; + foreach ($config['js'] as $name => $filename) { + if (in_array($name, $loaded)) { + continue; + } + + array_push($loaded, $name); + + $url_js = ui_get_full_url($filename); + $output .= ''."\n\t"; + } + + /* + * End load JS + */ + include_once __DIR__.'/graphs/functions_flot.php'; $output .= include_javascript_dependencies_flot_graph(true); @@ -2760,6 +2760,346 @@ function ui_progress( } +/** + * Generate needed code to print a datatables jquery plugin. + * + * @param array $parameters All desired data using following format: + * [ + * 'print' => true (by default printed) + * 'id' => datatable id. + * 'class' => datatable class. + * 'style' => datatable style. + * 'order' => '9, "desc"'. Column index (starting by 1) and sort direction. + * 'ajax_url' => 'include/ajax.php' ajax_url. + * 'ajax_postprocess' => a javscript function to postprocess data received + * by ajax call. It is applied foreach row and must + * use following format: + * * [code] + * * function (item) { + * * // Process received item, for instance, name: + * * tmp = '' + item.name + ''; + * * item.name = tmp; + * * } + * * [/code] + * 'columns' => [ + * 'column1' :: Used as th text. Direct text entry. It could be array: + * OR + * [ + * 'id' => th id. + * 'class' => th class. + * 'style' => th style. + * 'text' => 'column1'. + * ] + * ], + * 'datacolumns' => [ + * 'column1', + * 'column2', + * ... + * ], + * 'form' => [ + * 'html' => 'html code' a directly defined inputs in HTML. + * 'search_button_class' => search button class. + * 'class' => form class. + * 'id' => form id. + * 'style' => form style. + * 'js' => optional extra actions onsubmit. + * 'inputs' => [ + * 'label' => Input label. + * 'type' => Input type. + * 'value' => Input value. + * 'name' => Input name. + * 'id' => Input id. + * 'options' => [ + * 'option1' + * 'option2' + * ... + * ] + * ] + * ], + * ] + * End. + * + * @return string HTML code with datatable. + * @throws Exception On error. + */ +function ui_print_datatable(array $parameters) +{ + if (isset($parameters['id'])) { + $table_id = $parameters['id']; + } else { + $table_id = uniqid('datatable_'); + } + + if (!isset($parameters['order'])) { + $parameters['order'] = '0, "asc"'; + } + + if (!isset($parameters['ajax_url'])) { + throw new Exception('Parameter ajax_url is required'); + } + + if (!isset($parameters['ajax_data'])) { + $parameters['ajax_data'] = ''; + } + + $search_button_class = 'sub search'; + if (isset($parameters['search_button_class'])) { + $search_button_class = $parameters['search_button_class']; + } + + if (isset($parameters['pagination_options'])) { + $pagination_options = $parameters['pagination_options']; + } else { + $pagination_options = [ + [ + 10, + 25, + 100, + 200, + 500, + 1000, + -1, + ], + [ + 10, + 25, + 100, + 200, + 500, + 1000, + 'All', + ], + ]; + } + + if (!is_array($parameters['datacolumns'])) { + $parameters['datacolumns'] = $parameters['columns']; + } + + // Datatable filter. + if (isset($parameters['form']) && is_array($parameters['form'])) { + if (isset($parameters['form']['id'])) { + $form_id = $parameters['form']['id']; + } else { + $form_id = uniqid('datatable_filter_'); + } + + if (isset($parameters['form']['class'])) { + $form_class = $parameters['form']['class']; + } else { + $form_class = ''; + } + + if (isset($parameters['form']['style'])) { + $form_style = $parameters['form']['style']; + } else { + $form_style = ''; + } + + if (isset($parameters['form']['js'])) { + $form_js = $parameters['form']['js']; + } else { + $form_js = ''; + } + + $filter = ''; + + if (isset($parameters['form']['html'])) { + $filter .= $parameters['form']['html']; + } + + $filter .= '
    '; + + foreach ($parameters['form']['inputs'] as $input) { + $filter .= '
  • '; + $filter .= ''; + if ($input['type'] != 'select') { + $filter .= ''; + } else { + // Select. + $filter .= ''; + } + + $filter .= '
  • '; + } + + // Search button. + $filter .= '
  • '; + $filter .= ''; + $filter .= '
  • '; + + $filter .= '
'; + $filter = ui_toggle( + $filter, + __('Filter'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border' + ); + } else if (isset($parameters['form_html'])) { + $filter = ui_toggle( + $parameters['form_html'], + __('Filter'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border' + ); + } + + if (!isset($parameters['columns']) || !is_array($parameters['columns'])) { + throw new Exception('[ui_print_datatable]: You must define columns for datatable'); + } + + // Base table. + $table = ''; + $table .= ''; + if (!is_array($parameters['columns'])) { + throw new Exception('[ui_print_datatable]: Parameter columns is required.'); + } + + foreach ($parameters['columns'] as $column) { + if (is_array($column)) { + $table .= ''; + } else { + $table .= ''; + } + } + + $table .= ''; + $table .= '
'.__($column['text']); + $table .= ''.__($column).'
'; + + // Javascript controller. + $js = ''; + + $output = $filter.$table.$js; + + ui_require_css_file('datatables.min', 'include/styles/js/'); + ui_require_javascript_file('datatables.min'); + ui_require_javascript_file('buttons.dataTables.min'); + ui_require_javascript_file('dataTables.buttons.min'); + ui_require_javascript_file('buttons.html5.min'); + ui_require_javascript_file('buttons.print.min'); + + $output = $include.$output; + + // Print datatable if needed. + if (!(isset($parameters['print']) && $parameters['print'] === false)) { + echo $output; + } + + return $output; +} + + /** * Returns a div wich represents the type received. * diff --git a/pandora_console/include/javascript/buttons.dataTables.min.js b/pandora_console/include/javascript/buttons.dataTables.min.js new file mode 100644 index 0000000000..90389767ac --- /dev/null +++ b/pandora_console/include/javascript/buttons.dataTables.min.js @@ -0,0 +1,5 @@ +/*! + DataTables styling wrapper for Buttons + ©2018 SpryMedia Ltd - datatables.net/license +*/ +(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net-dt","datatables.net-buttons"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);b&&b.fn.dataTable||(b=require("datatables.net-dt")(a,b).$);b.fn.dataTable.Buttons||require("datatables.net-buttons")(a,b);return c(b,a,a.document)}:c(jQuery,window,document)})(function(c,a,b,d){return c.fn.dataTable}); diff --git a/pandora_console/include/javascript/buttons.html5.min.js b/pandora_console/include/javascript/buttons.html5.min.js new file mode 100644 index 0000000000..deee7fee68 --- /dev/null +++ b/pandora_console/include/javascript/buttons.html5.min.js @@ -0,0 +1,35 @@ +/*! + HTML5 export buttons for Buttons and DataTables. + 2016 SpryMedia Ltd - datatables.net/license + + FileSaver.js (1.3.3) - MIT license + Copyright © 2016 Eli Grey - http://eligrey.com +*/ +(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(g){return f(g,window,document)}):"object"===typeof exports?module.exports=function(g,p,z,t){g||(g=window);p&&p.fn.dataTable||(p=require("datatables.net")(g,p).$);p.fn.dataTable.Buttons||require("datatables.net-buttons")(g,p);return f(p,g,g.document,z,t)}:f(jQuery,window,document)})(function(f,g,p,z,t,w){function A(a){for(var b="";0<=a;)b=String.fromCharCode(a%26+65)+b,a=Math.floor(a/ +26)-1;return b}function E(a,b){y===w&&(y=-1===C.serializeToString(f.parseXML(F["xl/worksheets/sheet1.xml"])).indexOf("xmlns:r"));f.each(b,function(b,c){if(f.isPlainObject(c))b=a.folder(b),E(b,c);else{if(y){var d=c.childNodes[0],e,h=[];for(e=d.attributes.length-1;0<=e;e--){var m=d.attributes[e].nodeName;var k=d.attributes[e].nodeValue;-1!==m.indexOf(":")&&(h.push({name:m,value:k}),d.removeAttribute(m))}e=0;for(m=h.length;e'+c),c=c.replace(/_dt_b_namespace_token_/g,":"),c=c.replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""));c=c.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");a.file(b,c)}})}function r(a,b,d){var c=a.createElement(b);d&&(d.attr&&f(c).attr(d.attr),d.children&&f.each(d.children,function(a,b){c.appendChild(b)}),null!==d.text&&d.text!==w&&c.appendChild(a.createTextNode(d.text))); +return c}function L(a,b){var d=a.header[b].length;a.footer&&a.footer[b].length>d&&(d=a.footer[b].length);for(var c=0,f=a.body.length;cd&&(d=e);if(401*a[1]?!0:!1};try{var C=new XMLSerializer,y}catch(a){}var F={"_rels/.rels":'', +"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'', +"xl/workbook.xml":'', +"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''}, +K=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(a){return a/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(a){return a/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63}, +{match:/^\-?[\d,]+\.\d{2}$/,style:64}];v.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(a){return a.i18n("buttons.copy","Copy")},action:function(a,b,d,c){this.processing(!0);var g=this;a=I(b,c);var e=b.buttons.exportInfo(c),h=H(c),m=a.str;d=f("
").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0});e.title&&(m=e.title+h+h+m);e.messageTop&&(m=e.messageTop+h+h+m);e.messageBottom&&(m=m+h+h+e.messageBottom);c.customize&&(m=c.customize(m,c,b));c=f("",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w(" '; - - echo ''; - - echo '
'; - // Floating menu - End. - ui_require_jquery_file('countdown'); } // Error div for ajax messages. @@ -627,570 +355,293 @@ echo "
"; echo '
'; -if (($section == 'validate') && ($ids[0] == -1)) { - $section = 'list'; - ui_print_error_message(__('No events selected')); +// Controls. +if (is_metaconsole() !== true) { + if (isset($config['event_replication']) + && $config['event_replication'] == 1 + ) { + if ($config['show_events_in_local'] == 0) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access event viewer. View disabled due event replication.' + ); + ui_print_info_message( + [ + 'message' => __( + 'Event viewer is disabled due event replication. For more information, please contact with the administrator' + ), + 'no_close' => true, + ] + ); + return; + } else { + $readonly = true; + } + } } -// Process validation (pass array or single value). -if ($validate) { - $ids = get_parameter('eventid', -1); - $comment = get_parameter('comment', ''); - $new_status = get_parameter('select_validate', 1); - $ids = explode(',', $ids); - $standby_alert = (bool) get_parameter('standby-alert'); +// Load filter form. +// Group. +$user_groups_array = users_get_groups_for_select( + $config['id_user'], + $access, + true, + true, + false +); +$data = html_print_select( + $user_groups_array, + 'id_group_filter', + $id_group_filter, + '', + '', + 0, + true, + false, + false, + 'w130' +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Event type. +$types = get_event_types(); +$types['not_normal'] = __('Not normal'); +$data = html_print_select( + $types, + 'event_type', + $event_type, + '', + __('All'), + '', + true +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Criticity - severity. +$severity_select .= html_print_select( + get_priorities(), + 'severity', + $severity, + '', + __('All'), + '-1', + true, + false, + false +); +$in = '
'; +$in .= $severity_select.'
'; +$inputs[] = $in; + +// Event status. +$data = html_print_select( + events_get_all_status(), + 'status', + $status, + '', + '', + '', + true +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Max hours old. +$data = html_print_input_text( + 'event_view_hr', + $event_view_hr, + '', + 5, + 255, + true +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Duplicates group { events | agents }. +$data = html_print_select( + [ + __('All events'), + __('Group events'), + __('Group agents'), + ], + 'group_rep', + $group_rep, + '', + '', + 0, + true +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Source. +$data = html_print_input_text('source', $source, '', 35, 255, true); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + + +// Extra ID. +$data = html_print_input_text('id_extra', $id_extra, '', 11, 255, true); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + +// Comment. +$data = html_print_input_text( + 'user_comment', + $user_comment, + '', + 35, + 255, + true +); +$in = '
'; +$in .= $data.'
'; +$inputs[] = $in; + + +// Advanced filter. +$adv_filter = ''; + +// Load view. +$filter = join('', $inputs); +$filter .= ui_toggle( + $adv_filter, + __('Advanced options'), + '', + '', + true, + true, + 'white_box white_box_opened', + 'no-border' +); + +try { + ui_print_datatable( + [ + 'id' => 'events', + 'class' => 'info_table', + 'style' => 'width: 100%;', + 'ajax_url' => 'operation/events/events', + 'ajax_data' => ['get_events' => 1], + 'pagination_options' => [ + [ + $config['block_size'], + 10, + 25, + 100, + 200, + 500, + 1000, + -1, + ], + [ + $config['block_size'], + 10, + 25, + 100, + 200, + 500, + 1000, + 'All', + ], + ], + 'form' => [ + 'class' => 'flex-row', + 'html' => $filter, + 'inputs' => [], + ], + 'columns' => [ + 'id_evento', + 'id_agente', + // 'id_usuario', + // 'id_grupo', + // 'estado', + 'evento', + 'agent_name', + 'timestamp', + // 'utimestamp', + // 'event_type', + // 'id_agentmodule', + // 'id_alert_am', + 'criticity', + 'user_comment', + 'tags', + // 'source', + // 'id_extra', + // 'critical_instructions', + // 'warning_instructions', + // 'unknown_instructions', + // 'owner_user', + // 'ack_utimestamp', + // 'custom_data', + // 'data', + // 'module_status', + // 'similar_ids', + // 'event_rep', + // 'timestamp_rep', + // 'timestamp_rep_min', + // 'module_name', + ], + 'ajax_postprocess' => ' + function (item) { + item.id_evento = "#"+item.id_evento; + var color = "'.COL_UNKNOWN.'"; + var text = "UNKNOWN"; + switch (item.criticity) { + case "'.EVENT_CRIT_CRITICAL.'": + text = "CRITICAL"; + color = "'.COL_CRITICAL.'"; + break; + + case "'.EVENT_CRIT_MAINTENANCE.'": + text = "MAINTENANCE"; + color = "'.COL_MAINTENANCE.'"; + break; + + case "'.EVENT_CRIT_INFORMATIONAL.'": + text = "INFORMATIONAL"; + color = "'.COL_INFORMATIONAL.'"; + break; + + case "'.EVENT_CRIT_MAJOR.'": + text = "MAJOR"; + color = "'.COL_MAJOR.'"; + break; + + case "'.EVENT_CRIT_MINOR.'": + text = "MINOR"; + color = "'.COL_MINOR.'"; + break; + + case "'.EVENT_CRIT_NORMAL.'": + text = "NORMAL"; + color = "'.COL_NORMAL.'"; + break; + + case "'.EVENT_CRIT_WARNING.'": + text = "WARNING"; + color = "'.COL_WARNING.'"; + break; - // Avoid to re-set inprocess events. - if ($new_status == 2) { - foreach ($ids as $key => $id) { - $event = events_get_event($id); - if ($event['estado'] == 2) { - unset($ids[$key]); } - } - } - - if (isset($ids[0]) && $ids[0] != -1) { - $return = events_change_status($ids, $new_status, $meta); - - if ($new_status == 1) { - ui_print_result_message( - $return, - __('Successfully validated'), - __('Could not be validated') - ); - } else if ($new_status == 2) { - ui_print_result_message( - $return, - __('Successfully set in process'), - __('Could not be set in process') - ); - } - } -} - -// Process deletion (pass array or single value). -if ($delete) { - $ids = (array) get_parameter('validate_ids', -1); - - // Discard deleting in progress events. - $in_process_status = db_get_all_rows_sql( - ' - SELECT id_evento - FROM tevento - WHERE estado=2' + item.criticity = \'
\' + text + "
"; + }', + ] ); - - foreach ($in_process_status as $val) { - if (($key = array_search($val['id_evento'], $ids)) !== false) { - unset($ids[$key]); - } - } - - if ($ids[0] != -1) { - $return = events_delete_event($ids, ($group_rep == 1), $meta); - ui_print_result_message( - $return, - __('Successfully deleted'), - __('Could not be deleted') - ); - } - - include_once $config['homedir'].'/operation/events/events_list.php'; -} else { - switch ($section) { - case 'list': - case 'history': - include_once $config['homedir'].'/operation/events/events_list.php'; - break; - } +} catch (Exception $e) { + ui_print_error_message($e->getMessage()); } -echo "
"; -echo "
"; -echo "
"; - -ui_require_jquery_file('bgiframe'); -ui_require_javascript_file('pandora_events'); +// Close viewer. enterprise_hook('close_meta_frame'); -ui_require_javascript_file('wz_jsgraphics'); -ui_require_javascript_file('pandora_visual_console'); - -$ignored_params['refresh'] = ''; -?> - \ No newline at end of file