Add qizard stp 3 and step 4 - #1748
This commit is contained in:
parent
099cd3bbe8
commit
4d9f029a61
|
@ -71,7 +71,7 @@ if($step == 1){
|
|||
}
|
||||
elseif($step == 2){
|
||||
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=2&id_cluster='".$id_cluster.">";
|
||||
echo "<form method='post' id='form_step_2' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=2&assign_agents=1&id_cluster=".$id_cluster."'>";
|
||||
|
||||
echo "<table width='50%' cellpadding=4 cellspacing=4 class='databox filters'>";
|
||||
|
||||
|
@ -101,10 +101,7 @@ elseif($step == 2){
|
|||
echo "<td class='datos'>";
|
||||
|
||||
$option_style = array();
|
||||
$cluster_agents_in = agents_get_cluster_agents(8);
|
||||
|
||||
html_debug($cluster_agents_in);
|
||||
|
||||
$cluster_agents_in = agents_get_cluster_agents($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);
|
||||
|
@ -132,9 +129,327 @@ elseif($step == 2){
|
|||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "<div style='width:50%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Next')."'></div>";
|
||||
echo "<div style='width:50%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update and go next')."'></div>";
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
elseif ($step == 3) {
|
||||
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&assign_modules=1&id_cluster=".$id_cluster."'>";
|
||||
|
||||
echo "<table width='50%' cellpadding=4 cellspacing=4 class='databox filters'>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Cluster name')."</b></td>";
|
||||
echo "<td class='datos'>".clusters_get_name($id_cluster)."</td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Adding common modules')."</b></td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
// $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;');
|
||||
echo "<b>" . __('Common in agents')."</b> " . html_print_image ('images/tick.png', true, $attr, false, true);
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
// $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;');
|
||||
echo "<b>" . __('Added common modules')."</b> " . html_print_image ('images/tick.png', true, $attr, false, true);
|
||||
echo "</td>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
|
||||
$cluster_agents_in = agents_get_cluster_agents($id_cluster);
|
||||
|
||||
// $cluster_modules_all = db_get_all_rows_sql('SELECT DISTINCT nombre, id_agente_modulo
|
||||
// FROM tagente_modulo t1
|
||||
// WHERE t1.delete_pending = 0
|
||||
// AND t1.id_agente IN ()
|
||||
// AND (
|
||||
// SELECT count(nombre)
|
||||
// FROM tagente_modulo t2
|
||||
// t1.nombre = t2.nombre
|
||||
// AND t2.id_agente IN () = (' . count($cluster_agents_in) . ')
|
||||
// ORDER BY nombre');
|
||||
|
||||
|
||||
html_print_select ($cluster_modules_all, 'id_modules[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style);
|
||||
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
echo "<br />";
|
||||
html_print_image ('images/darrowright.png', false, array ('id' => 'right', 'title' => __('Add modules to cluster')));
|
||||
echo "<br /><br /><br />";
|
||||
html_print_image ('images/darrowleft.png', false, array ('id' => 'left', 'title' => __('Drop modules to cluster')));
|
||||
echo "<br /><br /><br />";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
|
||||
html_print_select ($cluster_modules_in, 'id_agents2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style);
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "<div style='width:50%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update and Next')."'></div>";
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
elseif (condition) {
|
||||
html_debug('paso 4');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
function filterByGroup(idGroup, idSelect) {
|
||||
$('#loading_group').show();
|
||||
|
||||
$('#id_agents' + idSelect).empty ();
|
||||
search = $("#text-agent_filter" + idSelect).val();
|
||||
|
||||
jQuery.post (
|
||||
<?php
|
||||
echo "'" . ui_get_full_url(false, false, false, false) . "'";
|
||||
?>
|
||||
+ "/ajax.php", {
|
||||
"page" : "godmode/groups/group_list",
|
||||
"get_group_agents" : 1,
|
||||
"search" : search,
|
||||
"id_group" : idGroup,
|
||||
// Add a key prefix to avoid auto sorting in js object conversion
|
||||
"keys_prefix" : "_",
|
||||
// Juanma (22/05/2014) Fix: Dont show void agents in template wizard
|
||||
"show_void_agents" : 0
|
||||
},
|
||||
function (data, status) {
|
||||
|
||||
var group_agents = new Array();
|
||||
var group_agents_keys = new Array();
|
||||
|
||||
jQuery.each (data, function (id, value) {
|
||||
// Remove keys_prefix from the index
|
||||
id = id.substring(1);
|
||||
|
||||
group_agents.push(value);
|
||||
group_agents_keys.push(id);
|
||||
});
|
||||
|
||||
if(idSelect == '') {
|
||||
agents_out_keys = group_agents_keys;
|
||||
agents_out = group_agents;
|
||||
}
|
||||
else {
|
||||
agents_in_keys = group_agents_keys;
|
||||
agents_in = group_agents;
|
||||
}
|
||||
|
||||
refresh_agents($("#text-agent_filter"+idSelect).attr('value'), agents_out_keys, agents_out, $("#id_agents"+idSelect), <?php if (defined('METACONSOLE')) echo 1; else echo 0; ?>);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function filterByGroupMetaconsole(groupName, idSelect) {
|
||||
$('#loading_group_filter_group').show();
|
||||
|
||||
$('#id_agents'+idSelect).empty ();
|
||||
search = $("#text-agent_filter"+idSelect).val();
|
||||
|
||||
jQuery.post (<?php echo "'" . ui_get_full_url(false, false, false, false) . "'"; ?> + "/ajax.php",
|
||||
{
|
||||
"page" : "enterprise/meta/include/ajax/wizard.ajax",
|
||||
"action" : "get_group_agents",
|
||||
"separator" : "|",
|
||||
"only_meta" : 0,
|
||||
"agent_search" : search,
|
||||
"no_filter_tag" : true,
|
||||
"acl_access": "AR",
|
||||
<?php
|
||||
if ($strict_user)
|
||||
echo '"id_group" : groupName';
|
||||
else
|
||||
echo '"group_name" : groupName';
|
||||
?>
|
||||
},
|
||||
function (data, status) {
|
||||
$('#loading_group_filter_group').hide();
|
||||
|
||||
var group_agents = new Array();
|
||||
var group_agents_keys = new Array();
|
||||
|
||||
jQuery.each (data, function (id, value) {
|
||||
group_agents.push(value);
|
||||
group_agents_keys.push(id);
|
||||
});
|
||||
|
||||
if(idSelect == '') {
|
||||
agents_out_keys = group_agents_keys;
|
||||
agents_out = group_agents;
|
||||
}
|
||||
else {
|
||||
agents_in_keys = group_agents_keys;
|
||||
agents_in = group_agents;
|
||||
}
|
||||
|
||||
refresh_agents($("#text-agent_filter"+idSelect).attr('value'), agents_out_keys, agents_out, $("#id_agents"+idSelect), <?php if (is_metaconsole()) echo 1; else echo 0; ?>);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function refresh_agents(start_search, keys, values, select, metaconsole) {
|
||||
var n = 0;
|
||||
var i = 0;
|
||||
select.empty();
|
||||
|
||||
// Fix: Remove agents inside the template from agent selector
|
||||
$('#id_agents2 option').each(function(){
|
||||
|
||||
var out_agent = $(this).val();
|
||||
|
||||
if (metaconsole) {
|
||||
var out_split = out_agent.split('|');
|
||||
|
||||
if (out_split[0].length > 0)
|
||||
var out_agent = out_split[0] + '|' + out_split[1];
|
||||
}
|
||||
|
||||
if (out_agent) {
|
||||
|
||||
keys.forEach(function(it) {
|
||||
|
||||
var it_data = it;
|
||||
if (metaconsole) {
|
||||
var it_split = it.split('|');
|
||||
var it_data = it_split[0] + '|' + it_split[1];
|
||||
}
|
||||
|
||||
if (it_data == out_agent) {
|
||||
|
||||
var index = keys.indexOf(it);
|
||||
|
||||
// Remove from array!
|
||||
values.splice(index, 1);
|
||||
keys.splice(index, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
values.forEach(function(item) {
|
||||
var re = new RegExp(start_search,"gi");
|
||||
|
||||
match = item.match(re);
|
||||
|
||||
if (match != null) {
|
||||
select.append ($("<option></option>").attr("value", keys[n]).html(values[n]));
|
||||
i++;
|
||||
}
|
||||
n++;
|
||||
});
|
||||
if (i == 0) {
|
||||
$(select).empty ();
|
||||
$(select).append ($("<option></option>").attr ("value", 0).html ('<?php echo __('None');?>'));
|
||||
}
|
||||
|
||||
$('.loading_div').hide();
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
if ($('#hidden-metaconsole_activated').val() == 1) {
|
||||
filterByGroupMetaconsole($("#group").val(), '');
|
||||
}
|
||||
else {
|
||||
filterByGroup($("#group").val(), '');
|
||||
}
|
||||
|
||||
$("select[name='group']").change(function(){
|
||||
if ($('#hidden-metaconsole_activated').val() == 1) {
|
||||
filterByGroupMetaconsole($(this).val(), '');
|
||||
}
|
||||
else {
|
||||
filterByGroup($(this).val(), '');
|
||||
}
|
||||
});
|
||||
|
||||
$("#text-agent_filter").keyup (function () {
|
||||
$('#loading_filter').show();
|
||||
refresh_agents($(this).val(), agents_out_keys, agents_out, $("#id_agents"), <?php if (is_metaconsole()) echo 1; else echo 0; ?>);
|
||||
});
|
||||
|
||||
$("input[name='select_all_left']").click(function () {
|
||||
$('#id_agents option').map(function() {
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$("input[name='select_all_right']").click(function () {
|
||||
$('#id_agents2 option').map(function() {
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#right").click (function () {
|
||||
jQuery.each($("select[name='id_agents[]'] option:selected"), function (key, value) {
|
||||
|
||||
|
||||
agent_name = $(value).html();
|
||||
if (agent_name != <?php echo "'".__('None')."'"; ?>){
|
||||
id_agent = $(value).attr('value');
|
||||
|
||||
//Remove the none value
|
||||
$("#id_agents2").find("option[value='']").remove();
|
||||
|
||||
$("select[name='id_agents2[]']").append($("<option>").val(id_agent).html('<i>' + agent_name + '</i>'));
|
||||
$("#id_agents").find("option[value='" + id_agent + "']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#left").click(function() {
|
||||
jQuery.each($("select[name='id_agents2[]'] option:selected"), function (key, value) {
|
||||
agent_name = $(value).html();
|
||||
if (agent_name != <?php echo "'".__('None')."'"; ?>){
|
||||
id_agent = $(value).attr('value');
|
||||
$("select[name='id_agents[]']").append($("<option>").val(id_agent).html('<i>' + agent_name + '</i>'));
|
||||
$("#id_agents2").find("option[value='" + id_agent + "']").remove();
|
||||
}
|
||||
|
||||
//If empty the selectbox
|
||||
if ($("#id_agents2 option").length == 0) {
|
||||
$("select[name='id_agents2[]']")
|
||||
.append($("<option>").val("")
|
||||
.html("<?php echo __('None'); ?>"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( "#form_step_2" ).submit(function( event ) {
|
||||
if($( "#id_agents2 option" ).val() == ''){
|
||||
alert( <?php echo "'" . __('Please set agent distinct than ') . '"' . __('None') . '"' . "'"; ?> );
|
||||
event.preventDefault();
|
||||
}
|
||||
else{
|
||||
$("#id_agents2>option").prop("selected", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -32,8 +32,7 @@ $id_cluster = get_parameter('id_cluster',0);
|
|||
if($step == 1){
|
||||
|
||||
$add_cluster = (bool) get_parameter('add_cluster', false);
|
||||
$update_graph = (bool) get_parameter('update_cluster', false);
|
||||
$id_cluster = (int) get_parameter('id', 0);
|
||||
$update_cluster = (bool) get_parameter('update_cluster', false);
|
||||
|
||||
if ($add_cluster) {
|
||||
$name = get_parameter_post ("name");
|
||||
|
@ -85,6 +84,91 @@ if ($add_cluster) {
|
|||
$edit_cluster = false;
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($step == 2) {
|
||||
|
||||
$assign_agents = get_parameter('assign_agents',0);
|
||||
$cluster_agents = get_parameter('id_agents2',null); //abajao en assign
|
||||
|
||||
if($assign_agents){
|
||||
|
||||
$values_cluster_agents = array(
|
||||
'id_cluster' => $id_cluster,
|
||||
'id_agent' => $cluster_agents
|
||||
);
|
||||
|
||||
$agents_preasigned = db_get_all_rows_sql('select id_agent from tcluster_agent where id_cluster ='.$id_cluster);
|
||||
|
||||
foreach ($values_cluster_agents['id_agent'] as $key => $value) {
|
||||
|
||||
$tcluster_agent = db_process_sql('insert into tcluster_agent values ('.$id_cluster.','.$value.')');
|
||||
|
||||
if ($tcluster_agent !== false){
|
||||
db_pandora_audit("Report management", "Agent #$value assigned to cluster #$id_cluster");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign agent to cluster");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($agents_preasigned as $key => $value) {
|
||||
|
||||
if(!in_array($value['id_agent'],$values_cluster_agents['id_agent'])){
|
||||
$tcluster_agent_delete = db_process_sql('delete from tcluster_agent where id_agent = '.$value['id_agent'].' and id_cluster = '.$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&id_cluster=".$id_cluster);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
elseif ($step == 3) {
|
||||
|
||||
|
||||
|
||||
|
||||
$assign_modules = get_parameter('assign_modules',0);
|
||||
$cluster_modules = get_parameter('id_modules2',null); //abajao en assign
|
||||
|
||||
if($assign_modules){
|
||||
|
||||
$values_cluster_modules = array(
|
||||
'id_cluster' => $id_cluster,
|
||||
'id_module' => $cluster_modules
|
||||
);
|
||||
|
||||
// $modules_preasigned = db_get_all_rows_sql('select id_agent from tcluster_agent where id_cluster ='.$id_cluster);
|
||||
//
|
||||
// foreach ($values_cluster_agents['id_agent'] as $key => $value) {
|
||||
//
|
||||
// $tcluster_agent = db_process_sql('insert into tcluster_agent values ('.$id_cluster.','.$value.')');
|
||||
//
|
||||
// if ($tcluster_agent !== false){
|
||||
// db_pandora_audit("Report management", "Agent #$value assigned to cluster #$id_cluster");
|
||||
// }
|
||||
// else{
|
||||
// db_pandora_audit("Report management", "Fail try to assign agent to cluster");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// foreach ($agents_preasigned as $key => $value) {
|
||||
//
|
||||
// if(!in_array($value['id_agent'],$values_cluster_agents['id_agent'])){
|
||||
// $tcluster_agent_delete = db_process_sql('delete from tcluster_agent where id_agent = '.$value['id_agent'].' and id_cluster = '.$id_cluster);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
@ -92,9 +176,6 @@ ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", f
|
|||
|
||||
$active_tab = get_parameter('tab', 'main');
|
||||
|
||||
|
||||
|
||||
|
||||
switch ($active_tab) {
|
||||
case 'main':
|
||||
require_once('godmode/reporting/cluster_builder.main.php');
|
||||
|
|
|
@ -32,7 +32,15 @@ function clusters_get_name ($id_cluster, $case = 'none') {
|
|||
|
||||
function agents_get_cluster_agents ($id_cluster){
|
||||
$agents = db_get_all_rows_filter("tcluster_agent", array("id_cluster" => $id_cluster), "id_agent");
|
||||
return ($agents);
|
||||
|
||||
$post_agent = array();
|
||||
|
||||
foreach ($agents as $key => $value) {
|
||||
|
||||
$post_agent[$value['id_agent']] = agents_get_alias($value['id_agent']);
|
||||
}
|
||||
|
||||
return ($post_agent);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue