From cd1b7daa008b447f33191f9d838e2bbf436f3856 Mon Sep 17 00:00:00 2001
From: Jose Gonzalez <jose.gonzalez@artica.es>
Date: Mon, 20 Sep 2021 12:16:08 +0200
Subject: [PATCH] Fix select fields size

---
 .../agentes/module_manager_editor_common.php  |  9 ++--
 pandora_console/include/functions_html.php    | 45 +++++++++++--------
 pandora_console/operation/tree.php            | 44 ++++++++++++------
 3 files changed, 61 insertions(+), 37 deletions(-)

diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php
index 36efc20290..34681f509b 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_common.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_common.php
@@ -26,7 +26,7 @@
  * ============================================================================
  */
 
-// Begin
+// Begin.
 require_once $config['homedir'].'/include/functions_modules.php';
 require_once $config['homedir'].'/include/functions_categories.php';
 require_once $config['homedir'].'/include/graphs/functions_d3.php';
@@ -273,7 +273,8 @@ $table_simple->data[0][3] .= html_print_select_from_sql(
     true,
     false,
     true,
-    $disabledBecauseInPolicy
+    $disabledBecauseInPolicy,
+    'width: 150px'
 );
 
 if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) {
@@ -358,7 +359,7 @@ if (!$edit) {
         false,
         '',
         false,
-        false,
+        'width:200px',
         false,
         100
     );
@@ -637,7 +638,7 @@ $table_advanced->data[1][4] = html_print_extended_select_for_post_process(
     '0',
     false,
     true,
-    false,
+    'width:10em',
     false,
     $disabledBecauseInPolicy
 );
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index b9d6397655..87093dac0a 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -1774,6 +1774,12 @@ function html_print_extended_select_for_post_process(
         $uniq_name = $name;
     }
 
+    $style = 'font-size: xx-small;';
+
+    if ($select_style !== false) {
+        $style .= sprintf(' %s', $select_style);
+    }
+
     ob_start();
 
     echo '<div id="'.$uniq_name.'_default" style="w100p inline_line">';
@@ -1789,7 +1795,7 @@ function html_print_extended_select_for_post_process(
             false,
             '',
             $disabled,
-            'font-size: xx-small;'.$select_style
+            $style
         );
         echo ' <a href="javascript:">'.html_print_image(
             'images/pencil.png',
@@ -1840,20 +1846,20 @@ function html_print_extended_select_for_post_process(
 /**
  * Render a pair of select for times and text box for set the time more fine.
  *
- * @param string  $name          Select form name
- * @param variant $selected      Current selected value. Can be a single value or an array of selected values (in combination with multiple)
+ * @param string  $name          Select form name.
+ * @param mixed   $selected      Current selected value. Can be a single value or an array of selected values (in combination with multiple).
  * @param string  $script        Javascript onChange (select) code.
  * @param string  $nothing       Label when nothing is selected.
- * @param variant $nothing_value Value when nothing is selected
+ * @param mixed   $nothing_value Value when nothing is selected.
  * @param integer $size          Size of the input.
  * @param boolean $return        Whether to return an output string or echo now (optional, echo by default).
- * @param boolean $select_style  Wherter to assign to combo a unique name (to have more than one on same page, like dashboard)
- * @param boolean $unique_name
- * @param string  $class
- * @param boolean $readonly
- * @param string  $custom_fields
- * @param string  $style_icon
- * @param boolean $no_change
+ * @param boolean $select_style  Wherter to assign to combo a unique name (to have more than one on same page, like dashboard).
+ * @param boolean $unique_name   Uunique name value.
+ * @param string  $class         Class value.
+ * @param boolean $readonly      Readonly value.
+ * @param string  $custom_fields Custom fields value.
+ * @param string  $style_icon    Style icon value.
+ * @param boolean $no_change     No change value.
  * @param boolean $allow_zero    Allow the use of the value zero.
 
  * @return string HTML code if return parameter is true.
@@ -2024,13 +2030,14 @@ function html_print_extended_select_for_time(
 /**
  * Print selects to configure the cron of a module.
  *
- * @param string Run hour.
- * @param string Run minute.
- * @param string Run day of the month.
- * @param string Run month.
- * @param string Run day of the week.
- * @param bool Whether to return an output string or echo now (optional, echo by default).
- * @param bool Print cron grayed
+ * @param string  $hour     Run hour.
+ * @param string  $minute   Run minute.
+ * @param string  $mday     Run day of the month.
+ * @param string  $month    Run month.
+ * @param string  $wday     Run day of the week.
+ * @param boolean $return   Whether to return an output string or echo now (optional, echo by default).
+ * @param boolean $disabled If true, the control will show disabled.
+ * @param boolean $to       Print cron grayed.
  *
  * @return string HTML code if return parameter is true.
  */
@@ -5280,7 +5287,7 @@ function html_print_tabs(array $tabs)
  * Create a datalist.
  *
  * @param string $id          Use custom id.
- * @param string $values      Input values.
+ * @param array  $values      Input values.
  * @param string $returnparam Whether to return an output string or echo now (optional, echo by default).
  *
  * @return string HTML code if return parameter is true.
diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php
index a45fc9cde4..03f64c8107 100755
--- a/pandora_console/operation/tree.php
+++ b/pandora_console/operation/tree.php
@@ -1,16 +1,32 @@
 <?php
+/**
+ * Tree view.
+ *
+ * @category   Operation
+ * @package    Pandora FMS
+ * @subpackage Community
+ * @version    1.0.0
+ * @license    See below
+ *
+ *    ______                 ___                    _______ _______ ________
+ *   |   __ \.-----.--.--.--|  |.-----.----.-----. |    ___|   |   |     __|
+ *  |    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
+ * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
+ *
+ * ============================================================================
+ * Copyright (c) 2005-2021 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.
+ * ============================================================================
+ */
 
-// Pandora FMS - http://pandorafms.com
-// ==================================================
-// Copyright (c) 2005-2021 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 Lesser General Public License
-// as published by the Free Software Foundation; 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.
+// Begin.
 ui_require_css_file('tree');
 ui_require_css_file('fixed-bottom-box');
 
@@ -35,11 +51,11 @@ if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT
     $enterpriseEnable = true;
 }
 
-$url = 'index.php?'.'sec=estado&'.'sec2=operation/tree&'.'refr=0&'.'pure='.$pure.'&'.'tab=%s';
+$url = 'index.php?sec=estado&sec2=operation/tree&refr=0&pure='.$pure.'&tab=%s';
 
 $tabs = [];
 
-if (!$strict_acl) {
+if ($strict_acl === false) {
     $tabs['tag'] = [
         'text'   => "<a href='".sprintf($url, 'tag')."'>".html_print_image(
             'images/tag.png',
@@ -221,7 +237,7 @@ $row[] = __('Show full hirearchy');
 $row[] = html_print_checkbox('serach_hirearchy', $serach_hirearchy, false, true);
 
 $row[] = __('Agent status');
-$row[] = html_print_select($agent_status_arr, 'status_agent', $status_agent, '', '', 0, true);
+$row[] = html_print_select($agent_status_arr, 'status_agent', $status_agent, '', '', 0, true, false, true, '', false, 'width:10em');
 $row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_modules, true);
 
 // Button