mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
WIP Custom view fields
This commit is contained in:
parent
5c99a8138f
commit
bb15c39ef5
@ -1297,11 +1297,16 @@ if($build_table_custom_fields){
|
|||||||
if($build_table_child_custom_fields){
|
if($build_table_child_custom_fields){
|
||||||
$id_agent = get_parameter("id_agent", 0);
|
$id_agent = get_parameter("id_agent", 0);
|
||||||
$id_server = get_parameter("id_server", 0);
|
$id_server = get_parameter("id_server", 0);
|
||||||
|
$module_search = str_replace('amp;', '',get_parameter("module_search", ''));
|
||||||
|
|
||||||
if(!$id_server || !$id_agent){
|
if(!$id_server || !$id_agent){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($module_search != ''){
|
||||||
|
$name_where = " AND tam.nombre LIKE '%" . $module_search . "%'";
|
||||||
|
}
|
||||||
|
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
$server = metaconsole_get_connection_by_id ($id_server);
|
$server = metaconsole_get_connection_by_id ($id_server);
|
||||||
metaconsole_connect($server);
|
metaconsole_connect($server);
|
||||||
@ -1315,10 +1320,14 @@ if($build_table_child_custom_fields){
|
|||||||
FROM tagente_modulo tam
|
FROM tagente_modulo tam
|
||||||
INNER JOIN tagente_estado tae
|
INNER JOIN tagente_estado tae
|
||||||
ON tam.id_agente_modulo = tae.id_agente_modulo
|
ON tam.id_agente_modulo = tae.id_agente_modulo
|
||||||
WHERE tam.id_agente = %d",
|
WHERE tam.id_agente = %d
|
||||||
$id_agent
|
%s",
|
||||||
|
$id_agent,
|
||||||
|
$name_where
|
||||||
);
|
);
|
||||||
|
|
||||||
|
hd($query, true, true);
|
||||||
|
|
||||||
$modules = db_get_all_rows_sql ($query);
|
$modules = db_get_all_rows_sql ($query);
|
||||||
|
|
||||||
$table_modules = new stdClass();
|
$table_modules = new stdClass();
|
||||||
|
@ -2787,13 +2787,17 @@ function agents_get_status_clause($state, $show_not_init = true) {
|
|||||||
*
|
*
|
||||||
* @return array custom fields data.
|
* @return array custom fields data.
|
||||||
*/
|
*/
|
||||||
function get_custom_fields ($custom_field_id = false, $select = true) {
|
function get_custom_fields ($custom_field_id = false, $select = true, $display_on_front = false) {
|
||||||
$fields = ($select)
|
$fields = ($select)
|
||||||
? ' tcf.id_field, tcf.name '
|
? ' tcf.id_field, tcf.name '
|
||||||
: ' tcf.* ';
|
: ' tcf.* ';
|
||||||
|
|
||||||
$where = ($custom_field_id)
|
$where = ($custom_field_id)
|
||||||
? ' WHERE tcf.id_field ='.$custom_field_id
|
? ' WHERE tcf.id_field ='.$custom_field_id
|
||||||
|
: ' WHERE 1=1';
|
||||||
|
|
||||||
|
$display = ($display_on_front)
|
||||||
|
? ' AND tcf.display_on_front = 1'
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
$result_array=array();
|
$result_array=array();
|
||||||
@ -2801,9 +2805,12 @@ function get_custom_fields ($custom_field_id = false, $select = true) {
|
|||||||
$sql = sprintf("SELECT
|
$sql = sprintf("SELECT
|
||||||
%s
|
%s
|
||||||
FROM tagent_custom_fields tcf
|
FROM tagent_custom_fields tcf
|
||||||
%s",
|
%s
|
||||||
|
%s
|
||||||
|
",
|
||||||
$fields,
|
$fields,
|
||||||
$where
|
$where,
|
||||||
|
$display
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = db_get_all_rows_sql($sql);
|
$result = db_get_all_rows_sql($sql);
|
||||||
@ -2834,9 +2841,12 @@ function get_custom_fields ($custom_field_id = false, $select = true) {
|
|||||||
$sql = sprintf("SELECT
|
$sql = sprintf("SELECT
|
||||||
%s
|
%s
|
||||||
FROM tagent_custom_fields tcf
|
FROM tagent_custom_fields tcf
|
||||||
%s",
|
%s
|
||||||
|
%s
|
||||||
|
",
|
||||||
$fields,
|
$fields,
|
||||||
$where
|
$where,
|
||||||
|
$display
|
||||||
);
|
);
|
||||||
|
|
||||||
$result[]= db_get_all_rows_sql($sql);
|
$result[]= db_get_all_rows_sql($sql);
|
||||||
@ -2880,13 +2890,6 @@ function get_custom_fields_data ($custom_field_name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//XXX ACL GROUP
|
|
||||||
/*
|
|
||||||
$where_group = ($id_group)
|
|
||||||
? ' AND ta.id_grupo IN ($id_group)'
|
|
||||||
: '';
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(!is_metaconsole()){
|
if(!is_metaconsole()){
|
||||||
$sql = sprintf("SELECT tcf.id_field, tcf.name, tcd.description
|
$sql = sprintf("SELECT tcf.id_field, tcf.name, tcd.description
|
||||||
FROM tagent_custom_fields tcf
|
FROM tagent_custom_fields tcf
|
||||||
@ -2896,7 +2899,8 @@ function get_custom_fields_data ($custom_field_name) {
|
|||||||
ON tcd.id_agent = ta.id_agente
|
ON tcd.id_agent = ta.id_agente
|
||||||
WHERE tcd.description <> ''
|
WHERE tcd.description <> ''
|
||||||
AND tcf.name = '%s'
|
AND tcf.name = '%s'
|
||||||
GROUP BY tcf.id_field, tcd.description", $custom_field_name
|
GROUP BY tcf.id_field, tcd.description",
|
||||||
|
$custom_field_name
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = db_get_all_rows_sql($sql);
|
$result = db_get_all_rows_sql($sql);
|
||||||
@ -3182,30 +3186,6 @@ function agent_counters_custom_fields($filters){
|
|||||||
$final_result['counters_name'] = $array_data;
|
$final_result['counters_name'] = $array_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if(isset($data) && is_array($data)){
|
|
||||||
$data = array_reduce($data, function ($data, $item) {
|
|
||||||
$node_id = (int) $item["id_server"];
|
|
||||||
$agent_id = (int) $item["id_agente"];
|
|
||||||
$description = $item["description"];
|
|
||||||
if (!isset($data["descriptions_by_node_and_agent"][$node_id])) {
|
|
||||||
$data["descriptions_by_node_and_agent"][$node_id] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data["descriptions_by_node_and_agent"][$node_id][$agent_id] = $description;
|
|
||||||
|
|
||||||
$data["id_pairs_for_query"] .= (!empty($data["id_pairs_for_query"]) ? "," : "")
|
|
||||||
. "(" . $item["ids"] . ")";
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}, array(
|
|
||||||
"descriptions_by_node_and_agent" => array(),
|
|
||||||
"id_pairs_for_query" => ""
|
|
||||||
));
|
|
||||||
|
|
||||||
$final_result['indexed_descriptions'] = $data["descriptions_by_node_and_agent"];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$final_result['indexed_descriptions'] = $data;
|
$final_result['indexed_descriptions'] = $data;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user