diff --git a/pandora_console/godmode/reporting/cluster_builder.cluster_editor.php b/pandora_console/godmode/reporting/cluster_builder.cluster_editor.php deleted file mode 100644 index 0d40efe4b3..0000000000 --- a/pandora_console/godmode/reporting/cluster_builder.cluster_editor.php +++ /dev/null @@ -1,904 +0,0 @@ -'; - -if (defined('METACONSOLE')) { - - $sec = 'advanced'; -} -else { - - $sec = 'galertas'; -} - -$pure = get_parameter('pure', 0); - -/* Step 1 */ -if ($step == 1) - echo '
  • '; -elseif ($step > 1) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step') . ' 1 » '; - echo '' . __('Cluster settings') . ''; - echo ''; -} -else { - echo __('Step') . ' 1 » '; - echo '' . __('Cluster settings') . ''; -} -echo '
  • '; - -/* Step 2 */ -if ($step == 2) - echo '
  • '; -elseif ($step > 2) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step').' 2 » '; - echo ''.__('Cluster agents').''; - echo ''; -} -else { - echo __('Step').' 2 » '; - echo ''.__('Cluster agents').''; -} -echo '
  • '; - -/* Step 3 */ -if ($step == 3) - echo '
  • '; -elseif ($step > 3) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step').' 3 » '; - echo ''.__('Active modules').''; - echo ''; -} -else { - echo __('Step').' 3 » '; - echo ''.__('Active modules').''; -} -echo '
  • '; - -/* Step 3 */ -if ($step == 4) - echo '
  • '; -elseif ($step > 4) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step').' 4 » '; - echo ''.__('Modules limits').''; - echo ''; -} -else { - echo __('Step').' 4 » '; - echo ''.__('Modules limits').''; -} -echo '
  • '; - -/* Step 3 */ -if ($step == 5) - echo '
  • '; -elseif ($step > 5) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step').' 5 » '; - echo ''.__('Balanced modules').''; - echo ''; -} -else { - echo __('Step').' 5 » '; - echo ''.__('Balanced modules').''; -} -echo '
  • '; - -/* Step 3 */ -if ($step == 6) - echo '
  • '; -elseif ($step > 6) - echo '
  • '; -else - echo '
  • '; - -if ($id) { - echo ''; - echo __('Step').' 6 » '; - echo ''.__('Critical modules').''; - echo ''; -} -else { - echo __('Step').' 6 » '; - echo ''.__('Critical modules').''; -} -echo '
  • '; - -echo ''; -echo '
    '; - -if($step == 1){ - - if ($edit_cluster) - echo "
    "; - else - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo" "; - - echo "
    ".__('Cluster name')."".ui_print_help_tip (__("An agent with the same name of the cluster will be created, as well a special service with the same name"), true)."
    ".__('Cluster type').""; - echo ""; - - $cluster_types = array( - 'AA' => __('Ative - Active'), - 'AP' => __('Active - Pasive') - ); - - html_print_select ($cluster_types, 'cluster_type', 'AA'); - - echo "
    ".__('Description')."
    ".__('Group').""; - if (check_acl ($config['id_user'], 0, "RW")) - echo html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true); - elseif (check_acl ($config['id_user'], 0, "RM")) - echo html_print_select_groups($config['id_user'], 'RM', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true); - echo "
    "; - - if ($edit_cluster) { - echo "
    "; - } - else { - echo "
    "; - } - echo "
    "; - -} -elseif($step == 2){ - - echo "
    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding agents to the cluster')."
    "; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Agents in Cluster')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - $option_style = array(); - $cluster_agents_in = agents_get_cluster_agents_alias($id_cluster); - $cluster_agents_all = agents_get_group_agents(0, false, ''); - $cluster_agents_out = array(); - $cluster_agents_out = array_diff_key($template_agents_all, $template_agents_in); - - $cluster_agents_in_keys = array_keys($template_agents_in); - $cluster_agents_out_keys = array_keys($template_agents_out); - - html_print_select ($cluster_agents_all, 'id_agents[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'agent_right', 'title' => __('Add agents to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'agent_left', 'title' => __('Drop agents to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($cluster_agents_in, 'id_agents2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - echo "
    "; - echo "
    "; - -} -elseif ($step == 3) { - - echo "
    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding common modules')."
    "; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Common in agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Added common modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - $cluster_modules_in = items_get_cluster_items_name($id_cluster); - - $cluster_modules_all = db_get_all_rows_sql('select count(nombre) as total ,nombre, id_agente_modulo,id_agente FROM - tagente_modulo where id_agente in ('.$serialize_agents.') group by nombre having total = '.count($cluster_agents_in_id)); - - foreach ($cluster_modules_all as $key => $value) { - $cluster_modules_all_name[$value['nombre']] = $value['nombre']; - } - - $cluster_modules_all_diff = array_diff($cluster_modules_all_name,$cluster_modules_in); - - html_print_select ($cluster_modules_all_diff, 'name_modules[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'module_right', 'title' => __('Add modules to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'module_left', 'title' => __('Drop modules to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($cluster_modules_in, 'name_modules2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - echo "
    "; - echo "
    "; - -} -elseif ($step == 4) { - - echo "
    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $cluster_items = items_get_cluster_items_id_name($id_cluster); - - foreach ($cluster_items as $key => $value) { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - - } - - - echo "
    ".__('Common modules')."".__('Critical if')."".__('Warning if')."".__('Actions')."
    ".$value."   are down   are down
    "; - - echo "
    "; - - echo "
    "; - -} -elseif ($step == 5) { - - echo "
    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding balanced modules')."
    "; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Added balanced modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - - $balanced_modules_all = db_get_all_rows_sql('select nombre from tagente_modulo where id_agente in ('.$serialize_agents.')'); - - foreach ($balanced_modules_all as $key => $value) { - $balanced_modules_all_name[$value['nombre']] = $value['nombre']; - } - - $balanced_modules_in = items_get_cluster_items_name($id_cluster,'AP'); - - $balanced_modules_all_diff = array_diff($balanced_modules_all_name,$balanced_modules_in); - - html_print_select ($balanced_modules_all_diff, 'name_modules[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'module_right', 'title' => __('Add modules to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'module_left', 'title' => __('Drop modules to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($balanced_modules_in, 'name_modules2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - echo "
    "; - echo "
    "; - -} -elseif ($step == 6) { - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - - $balanced_modules_critical = items_get_cluster_items_id_critical($id_cluster); - - echo "
    "; - - echo "

    ".__('Balanced modules settings')."

    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - foreach ($balanced_modules_critical as $key => $value) { - echo ""; - echo ""; - - - if($value){ - echo ""; - } - else{ - echo ""; - } - - echo ""; - echo ""; - - } - - echo "
    ".__('Balanced module')."".__('is critical module')."".__('Actions')."
    ".items_get_name($key)."
    "; - - echo "
    "; - - echo "
    "; -} - -?> - - \ No newline at end of file diff --git a/pandora_console/godmode/reporting/cluster_builder.main.php b/pandora_console/godmode/reporting/cluster_builder.main.php index 38f8bbb486..c96c852353 100644 --- a/pandora_console/godmode/reporting/cluster_builder.main.php +++ b/pandora_console/godmode/reporting/cluster_builder.main.php @@ -21,15 +21,6 @@ global $config; echo '
      '; -if (defined('METACONSOLE')) { - - $sec = 'advanced'; -} -else { - - $sec = 'galertas'; -} - $pure = get_parameter('pure', 0); /* Step 1 */ @@ -40,8 +31,14 @@ elseif ($step > 1) else echo '
    1. '; -if ($id) { - echo ''; +if ($step > 1 && !$update) { + echo ''; + echo __('Step') . ' 1 » '; + echo '' . __('Cluster settings') . ''; + echo ''; +} +elseif ($update) { + echo ''; echo __('Step') . ' 1 » '; echo '' . __('Cluster settings') . ''; echo ''; @@ -52,107 +49,165 @@ else { } echo '
    2. '; + + + + /* Step 2 */ if ($step == 2) - echo '
    3. '; + echo '
    4. '; elseif ($step > 2) echo '
    5. '; else - echo '
    6. '; + echo '
    7. '; -if ($id) { - echo ''; - echo __('Step').' 2 » '; - echo ''.__('Cluster agents').''; +if ($step > 2 && !$update) { + echo ''; + echo __('Step') . ' 2 » '; + echo '' . __('Cluster agents') . ''; + echo ''; +} +elseif ($update) { + echo ''; + echo __('Step') . ' 2 » '; + echo '' . __('Cluster agents') . ''; echo ''; } else { - echo __('Step').' 2 » '; - echo ''.__('Cluster agents').''; + echo __('Step') . ' 2 » '; + echo '' . __('Cluster agents') . ''; } echo '
    8. '; + + + + + /* Step 3 */ if ($step == 3) - echo '
    9. '; + echo '
    10. '; elseif ($step > 3) - echo '
    11. '; + echo '
    12. '; else - echo '
    13. '; + echo '
    14. '; -if ($id) { - echo ''; - echo __('Step').' 3 » '; - echo ''.__('Active modules').''; +if ($step > 3 && !$update) { + echo ''; + echo __('Step') . ' 3 » '; + echo '' . __('A/A modules') . ''; + echo ''; +} +elseif ($update) { + echo ''; + echo __('Step') . ' 3 » '; + echo '' . __('A/A modules') . ''; echo ''; } else { - echo __('Step').' 3 » '; - echo ''.__('Active modules').''; + echo __('Step') . ' 3 » '; + echo '' . __('A/A modules') . ''; } echo '
    15. '; + + + + + + + /* Step 3 */ if ($step == 4) - echo '
    16. '; + echo '
    17. '; elseif ($step > 4) - echo '
    18. '; + echo '
    19. '; else - echo '
    20. '; + echo '
    21. '; -if ($id) { - echo ''; - echo __('Step').' 4 » '; - echo ''.__('Modules limits').''; +if ($step > 4 && !$update) { + echo ''; + echo __('Step') . ' 4 » '; + echo '' . __('A/A modules limits') . ''; + echo ''; +} +elseif ($update) { + echo ''; + echo __('Step') . ' 4 » '; + echo '' . __('A/A modules limits') . ''; echo ''; } else { - echo __('Step').' 4 » '; - echo ''.__('Modules limits').''; + echo __('Step') . ' 4 » '; + echo '' . __('A/A modules limits') . ''; } echo '
    22. '; + + + + + + $type_cluster = clusters_get_cluster_id_type($id_cluster); if($type_cluster[$id_cluster] == 'AP'){ /* Step 3 */ if ($step == 5) - echo '
    23. '; + echo '
    24. '; elseif ($step > 5) - echo '
    25. '; + echo '
    26. '; else - echo '
    27. '; + echo '
    28. '; -if ($id) { - echo ''; - echo __('Step').' 5 » '; - echo ''.__('Balanced modules').''; +if ($step > 5 && !$update) { + echo ''; + echo __('Step') . ' 5 » '; + echo '' . __('A/P modules') . ''; + echo ''; +} +elseif ($update) { + echo ''; + echo __('Step') . ' 5 » '; + echo '' . __('A/P modules') . ''; echo ''; } else { - echo __('Step').' 5 » '; - echo ''.__('Balanced modules').''; + echo __('Step') . ' 5 » '; + echo '' . __('A/P modules') . ''; } echo '
    29. '; + + + + + + /* Step 3 */ if ($step == 6) - echo '
    30. '; + echo '
    31. '; elseif ($step > 6) - echo '
    32. '; + echo '
    33. '; else - echo '
    34. '; + echo '
    35. '; -if ($id) { - echo ''; - echo __('Step').' 6 » '; - echo ''.__('Critical modules').''; +if ($step > 6 && !$update) { + echo ''; + echo __('Step') . ' 6 » '; + echo '' . __('Critical A/P modules') . ''; + echo ''; +} +elseif ($update) { + echo ''; + echo __('Step') . ' 6 » '; + echo '' . __('Critical A/P modules') . ''; echo ''; } else { - echo __('Step').' 6 » '; - echo ''.__('Critical modules').''; + echo __('Step') . ' 6 » '; + echo '' . __('Critical A/P modules') . ''; } echo '
    36. '; @@ -164,15 +219,31 @@ echo '
      '; if($step == 1){ - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + + if(!$update){ + echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + + } + echo ""; echo ""; - echo ""; + echo ""; echo ""; + + echo ""; echo ""; echo" "; echo "
      ".__('Cluster name')."".ui_print_help_tip (__("An agent with the same name of the cluster will be created, as well a special service with the same name"), true)."
      "; + + if(!$update){ + echo " + "; + } + + echo "
      ".__('Cluster type').""; + echo ""; $cluster_types = array( @@ -183,36 +254,45 @@ if($step == 1){ html_print_select ($cluster_types, 'cluster_type', 'AA'); echo "
      ".__('Description')."
      ".__('Group').""; if (check_acl ($config['id_user'], 0, "RW")) - echo html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true); + echo html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'cluster_id_group', clusters_get_group($id_cluster), '', '', '', true); elseif (check_acl ($config['id_user'], 0, "RM")) - echo html_print_select_groups($config['id_user'], 'RM', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true); + echo html_print_select_groups($config['id_user'], 'RM', $return_all_groups, 'cluster_id_group', clusters_get_group($id_cluster), '', '', '', true); echo "
      "; - if ($edit_cluster) { - echo "
      "; + if(!$update){ + echo "
      "; } - else { - echo "
      "; + else{ + echo "
      "; } echo "
      "; } elseif($step == 2){ - echo "
      "; - + if(!$update){ + echo ""; + } + else{ + echo ""; + } + echo ""; echo ""; @@ -272,13 +352,25 @@ elseif($step == 2){ echo ""; echo "
      "; - echo "
      "; + if(!$update){ + echo "
      "; + } + else{ + echo "
      "; + } + echo "
      "; } elseif ($step == 3) { - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } + echo ""; @@ -352,14 +444,26 @@ elseif ($step == 3) { echo ""; echo ""; echo "
      "; - - echo "
      "; + + if(!$update){ + echo "
      "; + } + else{ + echo "
      "; + } + echo "
      "; } elseif ($step == 4) { - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } + echo ""; @@ -385,11 +489,21 @@ elseif ($step == 4) { echo "
      "; - echo "
      "; + if(!$update){ + echo "
      "; + } + else{ + echo "
      "; + } echo "
      "; - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } echo "
      "; @@ -398,7 +512,13 @@ elseif ($step == 4) { } elseif ($step == 5) { - echo ""; + if(!$update){ + echo ""; + } + else{ + echo ""; + } + echo ""; @@ -473,7 +593,14 @@ elseif ($step == 5) { echo ""; echo "
      "; - echo "
      "; + if(!$update){ + echo "
      "; + } + else{ + echo "
      "; + } + + echo "
      "; } @@ -496,7 +623,13 @@ elseif ($step == 6) { $balanced_modules_critical = items_get_cluster_items_id_critical($id_cluster); - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } + echo "

      ".__('Balanced modules settings')."

      "; @@ -527,11 +660,22 @@ elseif ($step == 6) { echo ""; - echo "
      "; + if(!$update){ + echo "
      "; + } + else{ + echo "
      "; + } + echo "
      "; - echo "
      "; + if(!$update){ + echo ""; + } + else{ + echo ""; + } echo "
      "; @@ -841,21 +985,13 @@ elseif ($step == 6) { - - - - - - - - - - - - - $( "#form_step_2" ).submit(function( event ) { - if($( "#id_agents2 option" ).val() == ''){ + + if($( "#id_agents2 option" ).length < 2){ + alert( ); + event.preventDefault(); + } + else if($( "#id_agents2 option" ).val() == ''){ alert( ); event.preventDefault(); } @@ -866,13 +1002,7 @@ elseif ($step == 6) { $( "#form_step_3" ).submit(function( event ) { - if($( "#name_modules2 option" ).val() == ''){ - alert( ); - event.preventDefault(); - } - else{ - $("#name_modules2>option").prop("selected", true); - } + $("#name_modules2>option").prop("selected", true); }); diff --git a/pandora_console/godmode/reporting/cluster_builder.php b/pandora_console/godmode/reporting/cluster_builder.php index a76ecf067d..4d632377f5 100644 --- a/pandora_console/godmode/reporting/cluster_builder.php +++ b/pandora_console/godmode/reporting/cluster_builder.php @@ -30,13 +30,26 @@ require_once('include/functions_clusters.php'); $step = get_parameter('step',0); $id_cluster = get_parameter('id_cluster',0); $delete_cluster = get_parameter('delete_cluster',0); +$edit_cluster = get_parameter('edit_cluster',0); $delete_module_aa = get_parameter('delete_module_aa',0); $delete_module_ap = get_parameter('delete_module_ap',0); +$update = get_parameter('update',0); + +$buttons['list'] = array('active' => false, + 'text' => '' . + html_print_image("images/list.png", true, array ("title" => __('Clusters list'))) .''); + +if($update){ + + $buttons['view'] = array('active' => false, + 'text' => '' . + html_print_image("images/operation.png", true, array ("title" => __('Cluster view'))) .''); + +} if($step == 1){ $add_cluster = (bool) get_parameter('add_cluster', false); -$update_cluster = (bool) get_parameter('update_cluster', false); if ($add_cluster) { $name = get_parameter_post ("name"); @@ -113,6 +126,20 @@ if ($add_cluster) { if(!$id_cluster) $edit_cluster = false; } +elseif ($update && $edit_cluster) { + + $name = get_parameter_post ("name"); + $description = get_parameter_post ("description"); + $idGroup = get_parameter_post ('cluster_id_group'); + + $id_agent_update = db_process_sql('update tagente set alias = "'.$name.'",comentarios = "'.$description.'",id_grupo = '.$idGroup.' where id_agente = (select id_agent from tcluster where id = '.$id_cluster.')'); + + $id_cluster_update = db_process_sql('update tcluster set name = "'.$name.'",description = "'.$description.'",`group` = '.$idGroup.' where id = '.$id_cluster); + + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); + + } + ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons); @@ -152,7 +179,13 @@ elseif ($step == 2) { } - header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&id_cluster=".$id_cluster); + if(!$update){ + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&id_cluster=".$id_cluster); + } + else{ + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); + } + } ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons); @@ -165,6 +198,14 @@ elseif ($step == 3) { if($assign_modules){ + if(!$cluster_modules || $cluster_modules[0] == ''){ + + $tcluster_agent_module_delete_id = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$id_cluster.' and prediction_module = 6'); + $tcluster_module_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$id_cluster.' and item_type = "AA"'); + + } + else{ + $modules_preasigned = db_get_all_rows_sql('select id,name from tcluster_item where id_cluster ='.$id_cluster); foreach ($cluster_modules as $key => $value) { @@ -237,9 +278,17 @@ elseif ($step == 3) { } - header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster); } + if(!$update){ + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster); + } + else{ + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); + } + + } + ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons); } @@ -291,10 +340,10 @@ elseif ($step == 3) { $cluster_type = clusters_get_cluster_id_type($id_cluster); - if($cluster_type[$id_cluster] == 'AP'){ + if($cluster_type[$id_cluster] == 'AP' && !$update){ header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=5&id_cluster=".$id_cluster); } - elseif ($cluster_type[$id_cluster] == 'AA') { + elseif ($cluster_type[$id_cluster] == 'AA' || $update) { header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); } @@ -310,6 +359,13 @@ elseif ($step == 3) { if($assign_balanced_modules){ + if(!$balanced_modules || $balanced_modules[0] == ''){ + + $tcluster_agent_module_delete_id = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$id_cluster.' and prediction_module = 7'); + $tcluster_module_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$id_cluster.' and item_type = "AP"'); + + } + else{ $balanced_modules_preasigned = db_get_all_rows_sql('select id,name,item_type from tcluster_item where id_cluster ='.$id_cluster.' and item_type = "AP"'); foreach ($balanced_modules as $key => $value) { @@ -400,8 +456,16 @@ elseif ($step == 3) { } + } + + if(!$update){ header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=6&id_cluster=".$id_cluster); - } + } + else{ + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); + } + + } ui_print_page_header (__('Cluster')." » ".clusters_get_name($id_cluster), "images/chart.png", false, "", false, $buttons); @@ -434,8 +498,8 @@ elseif ($step == 3) { } } - - header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); + + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); } @@ -495,8 +559,5 @@ switch ($active_tab) { case 'main': require_once('godmode/reporting/cluster_builder.main.php'); break; - case 'cluster_editor': - require_once('godmode/reporting/cluster_builder.cluster_editor.php'); - break; } ?> diff --git a/pandora_console/godmode/reporting/cluster_list.php b/pandora_console/godmode/reporting/cluster_list.php index e70aa21e06..11512597ff 100644 --- a/pandora_console/godmode/reporting/cluster_list.php +++ b/pandora_console/godmode/reporting/cluster_list.php @@ -143,7 +143,7 @@ ui_pagination (count($clusters)); } $data[6] = " - "; + "; array_push ($table->data, $data); } diff --git a/pandora_console/godmode/reporting/cluster_name_agents.php b/pandora_console/godmode/reporting/cluster_name_agents.php index 0247a10ffe..b4b3364aa1 100644 --- a/pandora_console/godmode/reporting/cluster_name_agents.php +++ b/pandora_console/godmode/reporting/cluster_name_agents.php @@ -35,13 +35,13 @@ foreach ($module_agents_value as $key => $value) { if ($value === reset($module_agents_value) && $module_ap) { - echo ''; + echo ''; } else{ echo ''; } - echo ''.agents_get_alias($key).''; + echo ''.agents_get_alias($key).''; echo ''.modules_get_agentmodule_name($value).''; echo ''; diff --git a/pandora_console/godmode/reporting/cluster_view.php b/pandora_console/godmode/reporting/cluster_view.php index e6946eed78..8db5783fb3 100644 --- a/pandora_console/godmode/reporting/cluster_view.php +++ b/pandora_console/godmode/reporting/cluster_view.php @@ -24,7 +24,7 @@ $buttons['list'] = array('active' => false, $buttons['editor'] = array('active' => false, - 'text' => '' . + 'text' => '' . html_print_image("images/gm_setup.png", true, array ("title" => __('Cluster editor'))) .''); diff --git a/pandora_console/include/functions_clusters.php b/pandora_console/include/functions_clusters.php index 5b89a44167..249f4a4fd0 100644 --- a/pandora_console/include/functions_clusters.php +++ b/pandora_console/include/functions_clusters.php @@ -30,6 +30,25 @@ function clusters_get_name ($id_cluster, $case = 'none') { } } +function clusters_get_description ($id_cluster, $case = 'none') { + $description = (string) db_get_value ('description', 'tcluster', 'id', (int) $id_cluster); + + switch ($case) { + case 'upper': + return mb_strtoupper($description, 'UTF-8'); + case 'lower': + return mb_strtolower($description, 'UTF-8'); + case 'none': + default: + return ($description); + } +} + +function clusters_get_group ($id_cluster) { + $group = (int) db_get_value ('`group`', 'tcluster', 'id', (int) $id_cluster); + return ($group); +} + function items_get_name ($id, $case = 'none') { $name = (string) db_get_value ('name', 'tcluster_item', 'id', (int) $id);