2010-08-25 Sergio Martin <sergio.martin@artica.es>

* pandoradb.sql
	operation/agentes/estado_generalagente.php
	operation/agentes/custom_fields.php
	operation/agentes/ver_agente.php
	operation/agentes/agent_fields.php
	extras/pandoradb_migrate_v3.1_to_v3.2.sql
	godmode/agentes/fields_manager.php
	godmode/agentes/configurar_agente.php
	godmode/agentes/configure_field.php
	godmode/agentes/agent_manager.php
	godmode/menu.php: Added the custom field feature
	including agents custom fields managment, agent
	custom field viewer, custom fields added at the 
	agent configuration, customization of the custom
	fields to display it in the agent details and
	the creation of two new tables into the sql scripts
	All for pending task: 3052918



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3181 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-08-25 12:04:42 +00:00
parent 47fc37c021
commit fe100460f5
12 changed files with 542 additions and 29 deletions

View File

@ -1,3 +1,23 @@
2010-08-25 Sergio Martin <sergio.martin@artica.es>
* pandoradb.sql
operation/agentes/estado_generalagente.php
operation/agentes/custom_fields.php
operation/agentes/ver_agente.php
operation/agentes/agent_fields.php
extras/pandoradb_migrate_v3.1_to_v3.2.sql
godmode/agentes/fields_manager.php
godmode/agentes/configurar_agente.php
godmode/agentes/configure_field.php
godmode/agentes/agent_manager.php
godmode/menu.php: Added the custom field feature
including agents custom fields managment, agent
custom field viewer, custom fields added at the
agent configuration, customization of the custom
fields to display it in the agent details and
the creation of two new tables into the sql scripts
All for pending task: 3052918
2010-08-24 Sergio Martin <sergio.martin@artica.es>
* extensions/module_groups/icon_menu.png

View File

@ -94,3 +94,28 @@ l', 'onchange', 'unknown');
ALTER TABLE trecon_task ADD `snmp_community` varchar(64) NOT NULL default 'public';
-- -----------------------------------------------------
-- Table `tagent_custom_fields`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_custom_fields` (
`id_field` int(10) unsigned NOT NULL auto_increment,
`name` varchar(45) NOT NULL default '',
`display_on_front` tinyint(1) NOT NULL default 0,
PRIMARY KEY (`id_field`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tagent_custom_data`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_custom_data` (
`id_field` int(10) unsigned NOT NULL,
`id_agent` int(10) unsigned NOT NULL,
`description` text default '',
FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`)
ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (`id_field`, `id_agent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

View File

@ -92,7 +92,7 @@ $table->class = "databox_color";
$table->head = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->style[0] = 'font-weight: bold; width: 150px;';
$table->data = array ();
$table->data[0][0] = __('Agent name') .
@ -168,39 +168,50 @@ $table->data[6][0] = __('Server');
$table->data[6][1] = print_select (get_server_names (),
'server_name', $server_name, '', $none, 0, true);
// Custom ID
$table->data[7][0] = __('Custom ID');
$table->data[7][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true);
// Description
$table->data[8][0] = __('Description');
$table->data[8][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true);
$table->data[7][0] = __('Description');
$table->data[7][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true);
print_table ($table);
unset($table);
$table->width = '95%';
$table->class = "databox_color";
$table->head = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; width: 150px;';
$table->data = array ();
// Custom ID
$table->data[0][0] = __('Custom ID');
$table->data[0][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true);
// Learn mode / Normal mode
$table->data[9][0] = __('Module definition').print_help_icon("module_definition", true);
$table->data[9][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[9][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[1][0] = __('Module definition').print_help_icon("module_definition", true);
$table->data[1][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[1][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true);
// Status (Disabled / Enabled)
$table->data[10][0] = __('Status');
$table->data[10][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[10][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[2][0] = __('Status');
$table->data[2][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[2][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
// Remote configuration
$table->data[11][0] = __('Remote configuration');
$table->data[3][0] = __('Remote configuration');
if (!$new_agent) {
if (file_exists ($filename['md5'])) {
$table->data[11][1] = date ("F d Y H:i:s", fileatime ($filename['md5']));
$table->data[3][1] = date ("F d Y H:i:s", fileatime ($filename['md5']));
// Delete remote configuration
$table->data[11][1] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;disk_conf_delete=1&amp;id_agente='.$id_agente.'">';
$table->data[11][1] .= print_image ("images/cross.png", true).'</a>';
$table->data[3][1] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;disk_conf_delete=1&amp;id_agente='.$id_agente.'">';
$table->data[3][1] .= print_image ("images/cross.png", true).'</a>';
}
else
$table->data[11][1] = '<em>'.__('Not available').'</em>';
$table->data[3][1] = '<em>'.__('Not available').'</em>';
}
else
$table->data[11][1] = '<em>'.__('Not available').'</em>';
$table->data[3][1] = '<em>'.__('Not available').'</em>';
$listIcons = getArrayListIcons();
@ -209,8 +220,8 @@ foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index;
$path = 'images/gis_map/icons/'; //TODO set better method the path
$table->data[12][0] = __('Agent icon');
$table->data[12][1] = print_select($arraySelectIcon, "icon_path", $icon_path, "changeIcons();", __('None'), '', true) .
$table->data[4][0] = __('Agent icon');
$table->data[4][1] = print_select($arraySelectIcon, "icon_path", $icon_path, "changeIcons();", __('None'), '', true) .
'&nbsp;' . __('Without status') . ': <img id="icon_without_status" src="' . $path . $icon_path . 'default.png" style="display:none;" />' .
'&nbsp;' . __('Default') . ': <img id="icon_default" src="' . $path . $icon_path . 'default.png" style="display:none;" />' .
'&nbsp;' . __('Ok') . ': <img id="icon_ok" src="' . $path . $icon_path . 'ok.png" style="display:none;" />' .
@ -218,12 +229,44 @@ $table->data[12][1] = print_select($arraySelectIcon, "icon_path", $icon_path, "c
'&nbsp;' . __('Warning') . ': <img id="icon_warning" src="' . $path . $icon_path . 'warning.png" style="display:none;" />';
if ($config['activate_gis']) {
$table->data[13][0] = __('Ignore new GIS data:');
$table->data[13][1] = __('Disabled').' '.print_radio_button_extended ("update_gis_data", 0, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true);
$table->data[13][1] .= __('Active').' '.print_radio_button_extended ("update_gis_data", 1, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true);
$table->data[5][0] = __('Ignore new GIS data:');
$table->data[5][1] = __('Disabled').' '.print_radio_button_extended ("update_gis_data", 0, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true);
$table->data[5][1] .= __('Active').' '.print_radio_button_extended ("update_gis_data", 1, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true);
}
print_table ($table);
toggle(print_table ($table, true), __('Advanced options'));
unset($table);
$table->width = '95%';
$table->class = "databox_color";
$table->head = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; width: 150px;';
$table->data = array ();
$fields = get_db_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
$custom_value = get_db_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if($custom_value === false) {
$custom_value = '';
}
$data[1] = print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true);
array_push ($table->data, $data);
}
if(!empty($fields)) {
toggle(print_table ($table, true), __('Custom fields'));
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_agente) {

View File

@ -129,6 +129,16 @@ if ($create_agent) {
$icon_path = (string) get_parameter_post ("icon_path",'');
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$fields = get_db_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
$field_values = array();
foreach($fields as $field) {
$field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], '');
}
// Check if agent exists (BUG WC-50518-2)
if ($nombre_agente == "") {
$agent_creation_error = __('No agent name specified');
@ -150,6 +160,11 @@ if ($create_agent) {
'update_gis_data' => $update_gis_data));
enterprise_hook ('update_agent', array ($id_agente));
if ($id_agente !== false) {
// Create custom fields for this agent
foreach($field_values as $key => $value) {
process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
}
// Create address for this agent in taddress
agent_add_address ($id_agente, $direccion_agente);
@ -349,8 +364,10 @@ if (isset( $_GET["fix_module"])) {
__('Error normalizing module %s', $error));
}
$update_agent = (bool) get_parameter ('update_agent');
// Update AGENT
if (isset($_POST["update_agent"])) { // if modified some agent paramenter
if ($update_agent) { // if modified some agent paramenter
$id_agente = (int) get_parameter_post ("id_agente");
$nombre_agente = str_replace('`','&lsquo;',(string) get_parameter_post ("agente", ""));
$direccion_agente = (string) get_parameter_post ("direccion", '');
@ -377,6 +394,31 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
$icon_path = (string) get_parameter_post ("icon_path",'');
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$fields = get_db_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
$field_values = array();
foreach($fields as $field) {
$field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], '');
}
foreach($field_values as $key => $value) {
$old_value = get_db_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agente, 'id_field' => $key));
if($old_value === false) {
// Create custom field if not exist
process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
}else {
process_sql_update ('tagent_custom_data',
array('description' => $value),
array('id_field' => $key,'id_agent' => $id_agente));
}
}
//Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") {
echo '<h3 class="error">'.__('No agent name specified').'</h3>';

View File

@ -0,0 +1,64 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
check_login ();
if (! give_acl ($config['id_user'], 0, "PM")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access Group Management2");
require ("general/noaccess.php");
return;
}
$id_field = (int) get_parameter ('id_field', 0);
$name = (string) get_parameter ('name', '');
$display_on_front = (bool) get_parameter ('display_on_front', 0);
// Header
if ($id_field) {
$field = get_db_row_filter('tagent_custom_fields',array('id_field' => $id_field));
$name = $field['name'];
$display_on_front = $field['display_on_front'];
print_page_header (__("Update agent custom field"), "images/note.png", false, "", true, "");
} else {
print_page_header (__("Create agent custom field"), "images/note.png", false, "", true, "");
}
$table->width = '450px';
$table->data = array ();
$table->data[0][0] = __('Name');
$table->data[0][1] = print_input_text ('name', $name, '', 35, 100, true);
$table->data[1][0] = __('Display on front').print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true);
$table->data[1][1] = print_checkbox ('display_on_front', 1, $display_on_front, true);
echo '<form name="field" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/fields_manager">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_field) {
print_input_hidden ('update_field', 1);
print_input_hidden ('id_field', $id_field);
print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
} else {
print_input_hidden ('create_field', 1);
print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

View File

@ -0,0 +1,127 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
check_login();
if (! give_acl($config['id_user'], 0, "PM")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access Group Management");
require ("general/noaccess.php");
return;
}
// Header
print_page_header (__("Agents custom fields manager"), "images/note.png", false, "", true, "");
$create_field = (bool) get_parameter ('create_field');
$update_field = (bool) get_parameter ('update_field');
$delete_field = (bool) get_parameter ('delete_field');
$id_field = (int) get_parameter ('id_field', 0);
$name = (string) get_parameter ('name', '');
$display_on_front = (int) get_parameter ('display_on_front', 0);
/* Create field */
if ($create_field) {
/*Check if name field is empty*/
if ($name != "") {
$sql = sprintf ('INSERT INTO tagent_custom_fields (name, display_on_front)
VALUES ("%s", "%d")',
$name, $display_on_front);
$result = mysql_query ($sql);
} else {
$result = false;
}
if ($result) {
echo "<h3 class='suc'>".__('Field successfully created')."</h3>";
} else {
echo "<h3 class='error'>".__('There was a problem creating field')."</h3>"; }
}
/* Update field */
if ($update_field) {
/*Check if name field is empty*/
if( $name != "") {
$sql = sprintf ('UPDATE tagent_custom_fields SET name = "%s",
display_on_front = %d
WHERE id_field = %d',
$name, $display_on_front, $id_field);
$result = process_sql ($sql);
} else {
$result = false;
}
if ($result !== false) {
echo "<h3 class='suc'>".__('Field successfully updated')."</h3>";
} else {
echo "<h3 class='error'>".__('There was a problem modifying field')."</h3>";
}
}
/* Delete field */
if ($delete_field) {
$sql = sprintf ('DELETE FROM tagent_custom_fields WHERE id_field = %d', $id_field);
$result = process_sql ($sql);
if (!$result)
echo "<h3 class='error'>".__('There was a problem deleting field')."</h3>";
else
echo "<h3 class='suc'>".__('Field successfully deleted')."</h3>";
}
$table->width = '65%';
$table->head = array ();
$table->head[0] = __('Field');
$table->head[1] = __('Display on front').print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true);
$table->head[2] = __('Actions');
$table->align = array ();
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->data = array ();
$fields = get_db_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
if($field['display_on_front']) {
$data[1] = print_image('images/tick.png', true);
}else {
$data[1] = print_image('images/delete.png', true);
}
$data[2] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configure_field&id_field='.$field['id_field'].'"><img border="0" src="images/config.png" alt="' . __('Edit') . '" title="' . __('Edit') . '" /></a>';
$data[2] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/fields_manager&delete_field=1&id_field='.$field['id_field'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;"><img alt="' . __('Delete') . '" alt="' . __('Delete') . '" border="0" src="images/cross.png"></a>';
array_push ($table->data, $data);
}
print_table ($table);
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configure_field">';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_submit_button (__('Create field'), 'crt', false, 'class="sub next"');
echo '</div>';
echo '</form>';
?>

View File

@ -36,6 +36,7 @@ if (give_acl ($config['id_user'], 0, "AW")) {
$sub["godmode/groups/modu_group_list"]["text"] = __('Module groups');
$sub["godmode/agentes/planned_downtime"]["text"] = __('Scheduled downtime');
$sub["godmode/agentes/fields_manager"]["text"] = __('Manage custom fields');
}
enterprise_hook('agents_submenu');

View File

@ -0,0 +1,59 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once ("include/functions_agents.php");
if ($config['flash_charts']) {
require_once ("include/fgraph.php");
}
check_login ();
$id_agente = get_parameter_get ("id_agente", -1);
if ($id_agente === -1) {
echo '<h3 class="error">'.__('There was a problem loading agent').'</h3>';
return;
}
if (! give_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
audit_db ($config["id_user"], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access Agent General Information");
require_once ("general/noaccess.php");
return;
}
print_page_header (__('Agent custom fields'), 'images/note.png', false, "", false);
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox" style="width: 450px">';
// Custom fields
$fields = get_db_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1));
foreach($fields as $field) {
echo '<tr><td class="datos"><b>'.$field['name'].print_help_tip (__('Custom field'), true).'</b></td>';
$custom_value = get_db_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>';
}
echo '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
}
//End of table
echo '</table>';
?>

View File

@ -0,0 +1,79 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once ("include/functions_agents.php");
if ($config['flash_charts']) {
require_once ("include/fgraph.php");
}
check_login ();
$id_agente = get_parameter_get ("id_agente", -1);
if ($id_agente === -1) {
echo '<h3 class="error">'.__('There was a problem loading agent').'</h3>';
return;
}
if (! give_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
audit_db ($config["id_user"], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access Agent General Information");
require_once ("general/noaccess.php");
return;
}
$table->width = '65%';
$table->head = array ();
$table->head[0] = __('Field');
$table->head[1] = __('Display on front').print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true);
$table->head[2] = __('Description');
$table->align = array ();
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->data = array ();
$fields = get_db_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
if($field['display_on_front']) {
$data[1] = print_image('images/tick.png', true);
}else {
$data[1] = print_image('images/delete.png', true);
}
$custom_value = get_db_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>';
}
$data[2] = $custom_value;
array_push ($table->data, $data);
}
print_table ($table);
?>

View File

@ -160,6 +160,18 @@ $progress = getNextAgentContact($id_agente);
echo '<tr><td class="datos"><b>'.__('Next agent contact').'</b></td>';
echo '<td class="datos f9" colspan="2"><img src="include/fgraph.php?tipo=progress&percent='.$progress.'&height=20&width=200"></td></tr>';
// Custom fields
$fields = get_db_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1));
foreach($fields as $field) {
echo '<tr><td class="datos"><b>'.$field['name'].print_help_tip (__('Custom field'), true).'</b></td>';
$custom_value = get_db_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>';
}
echo '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
}
//End of table
echo '</table></div>';
?>

View File

@ -383,12 +383,28 @@ if ($config['activate_gis']) {
$gistab['active'] = false;
}
$onheader = array('manage' => $managetab, 'separator' => "", 'main' => $maintab, 'data' => $datatab, 'alert' => $alerttab, 'sla' => $slatab, 'inventory' => $inventorytab, 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab);
$custom_fields['text']= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=custom_fields&id_agente='.$id_agente.'">'
. print_image("images/note.png", true, array("title" => __('Custom fields')))
. '</a>';
if ($tab == 'custom_fields') {
$custom_fields['active'] = true;
} else {
$custom_fields['active'] = false;
}
$onheader = array('manage' => $managetab, 'separator' => "", 'main' => $maintab,
'data' => $datatab, 'alert' => $alerttab, 'sla' => $slatab,
'inventory' => $inventorytab, 'collection' => $collectiontab,
'group' => $grouptab, 'gis' => $gistab, 'custom' => $custom_fields);
print_page_header (__('Agent').'&nbsp;-&nbsp;'.mb_substr(get_agent_name($id_agente),0,25), $icon, false, "", false, $onheader);
switch ($tab) {
case "custom_fields":
require ("custom_fields.php");
break;
case "gis":
require ("gis_view.php");
break;
@ -416,7 +432,7 @@ switch ($tab) {
case "inventory":
enterprise_include ('operation/agentes/agent_inventory.php');
break;
case 'collection':
case "collection":
enterprise_include ('operation/agentes/collection_view.php');
break;
}

View File

@ -1132,10 +1132,35 @@ CREATE TABLE IF NOT EXISTS `tnetwork_map` (
-- Table `tsnmp_filter`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tsnmp_filter` (
CREATE TABLE IF NOT EXISTS `tsnmp_filter` (
`id_snmp_filter` int(10) unsigned NOT NULL auto_increment,
`description` varchar(255) default '',
`filter` varchar(255) default '',
PRIMARY KEY (`id_snmp_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tagent_custom_fields`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_custom_fields` (
`id_field` int(10) unsigned NOT NULL auto_increment,
`name` varchar(45) NOT NULL default '',
`display_on_front` tinyint(1) NOT NULL default 0,
PRIMARY KEY (`id_field`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tagent_custom_data`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tagent_custom_data` (
`id_field` int(10) unsigned NOT NULL,
`id_agent` int(10) unsigned NOT NULL,
`description` text default '',
FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`)
ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (`id_field`, `id_agent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;