From 8dbcffaa8bda7fde503e5f56256ea3b36d634c7a Mon Sep 17 00:00:00 2001
From: Jonathan <jonathan.leon@pandorafms.com>
Date: Tue, 7 Mar 2023 14:15:02 +0100
Subject: [PATCH] Buttons and view report

---
 .../reporting_builder.item_editor.php         | 29 ++++--
 pandora_console/include/functions_html.php    | 34 +++----
 pandora_console/include/styles/pandora.css    |  9 ++
 .../operation/reporting/reporting_viewer.php  | 98 ++++++-------------
 4 files changed, 79 insertions(+), 91 deletions(-)

diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
index ce755015ed..ec336eb290 100755
--- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php
+++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
@@ -2229,7 +2229,7 @@ $class = 'databox filters';
 
         <tr id="row_custom_graph"   class="datos">
             <td class="bolder"><?php echo __('Custom graph'); ?></td>
-            <td  >
+            <td class="toolbox-buttons">
                 <?php
                 if ($meta) {
                     $graphs = [];
@@ -2303,21 +2303,38 @@ $class = 'databox filters';
                     }
                 }
 
-                echo '&nbsp;';
+                if (!empty($style_button_create_custom_graph)) {
+                    $style_create = [
+                        'mode'  => 'link',
+                        'style' => 'display:none',
+                    ];
+                } else {
+                    $style_create = [ 'mode' => 'link' ];
+                }
+
+                if (!empty($style_button_edit_custom_graph)) {
+                    $style_edit = [
+                        'mode'  => 'link',
+                        'style' => 'display:none',
+                    ];
+                } else {
+                    $style_edit = [ 'mode' => 'link' ];
+                }
+
                 html_print_button(
                     __('Create'),
                     'create_graph',
                     false,
-                    'create_custom_graph();',
-                    'class="sub add" '.$style_button_create_custom_graph
+                    'create_custom_graph()',
+                    $style_create
                 );
 
                 html_print_button(
                     __('Edit'),
                     'edit_graph',
                     false,
-                    'edit_custom_graph();',
-                    'class="sub config" '.$style_button_edit_custom_graph
+                    'edit_custom_graph()',
+                    $style_edit
                 );
                 ?>
             </td>
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 693a14adb7..e9e60f3418 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -1361,29 +1361,27 @@ function html_print_select_multiple_filtered(
 
     $output .= '<div class="arrows-container flex-column">';
 
-    $output .= html_print_input(
+    $output .= html_print_image(
+        'images/plus.svg',
+        true,
         [
-            'type'    => 'image',
-            'src'     => 'images/darrowright.png',
-            'return'  => true,
-            'options' => [
-                'title'   => $texts['title-add'],
-                'onclick' => $add,
-                'class'   => 'invert_filter',
-            ],
+            'id'      => 'right_autorefreshlist',
+            'style'   => 'width: 24px; margin: 10px 10px 0;',
+            'alt'     => __('Push selected pages into autorefresh list'),
+            'title'   => __('Push selected pages into autorefresh list'),
+            'onclick' => $add,
         ]
     );
 
-    $output .= html_print_input(
+    $output .= html_print_image(
+        'images/minus.svg',
+        true,
         [
-            'type'    => 'image',
-            'src'     => 'images/darrowleft.png',
-            'return'  => true,
-            'options' => [
-                'title'   => $texts['title-del'],
-                'onclick' => $del,
-                'class'   => 'invert_filter',
-            ],
+            'id'      => 'left_autorefreshlist',
+            'style'   => 'width: 24px; margin: 10px 10px 0;',
+            'alt'     => __('Pop selected pages out of autorefresh list'),
+            'title'   => __('Pop selected pages out of autorefresh list'),
+            'onclick' => $del,
         ]
     );
 
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index eec5727f49..ba7425f137 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -11505,6 +11505,15 @@ div[role="dialog"] {
   /* font-weight: bold; */
 }
 
+.font-title-font {
+  font-size: 13px;
+  line-height: 16px;
+  color: #161628;
+  text-align: left;
+  margin-bottom: 10px;
+  font-weight: bold;
+}
+
 .preimage_container span {
   font-size: 11pt;
   line-height: 28px;
diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php
index 5c3ce7a73b..26e16c7f37 100755
--- a/pandora_console/operation/reporting/reporting_viewer.php
+++ b/pandora_console/operation/reporting/reporting_viewer.php
@@ -226,77 +226,52 @@ ui_print_standard_header(
 
 // ------------------- END HEADER ---------------------------------------
 // ------------------------ INIT FORM -----------------------------------
-$table = new stdClass();
-$table->id = 'controls_table';
-$table->width = '100%';
-$table->class = 'filter-table-adv';
+$table2 = new stdClass();
+$table2->id = 'controls_table';
+$table2->size[2] = '50%';
+$table2->size[3] = '50%';
+$table2->style[0] = 'text-align:center';
+$table2->style[1] = 'text-align:center';
+$table2->styleTable = 'border:none';
+
 if (defined('METACONSOLE')) {
-    $table->width = '100%';
-    $table->class = 'databox filters';
+    $table2->width = '100%';
+    $table2->class = 'databox filters';
 
-    $table->head[0] = __('View Report');
-    $table->head_colspan[0] = 5;
-    $table->headstyle[0] = 'text-align: center';
+    $table2->head[0] = __('View Report');
+    $table2->head_colspan[0] = 5;
+    $table2->headstyle[0] = 'text-align: center';
 }
 
-$table->style = [];
-$table->style[0] = 'vertical-align: middle';
-$table->rowspan[0][0] = 2;
-
 // Set initial conditions for these controls, later will be modified by javascript
 if (!$enable_init_date) {
-    $table->style[1] = 'display: none';
-    $table->style[2] = 'display: flex;align-items: baseline;';
     $display_to = 'none';
     $display_item = '';
 } else {
-    $table->style[1] = 'display: "block"';
-    $table->style[2] = 'display: flex;align-items: baseline;';
     $display_to = '';
     $display_item = 'none';
 }
 
-$table->size = [];
-$table->colspan[0][1] = 2;
-$table->data = [];
-$table->data[0][0] = html_print_image(
-    'images/reporting32.png',
-    true,
-    [
-        'width'  => '32',
-        'height' => '32',
-    ]
-);
-
-if (reporting_get_description($id_report)) {
-    $table->data[0][1] = '<div class="float-left">'.reporting_get_description($id_report).'</div>';
-} else {
-    $table->data[0][1] = '<div class="float-left">'.reporting_get_name($id_report).'</div>';
-}
-
-$table->data[0][1] .= '<div class="float-right">'.__('Set initial date').html_print_checkbox('enable_init_date', 1, $enable_init_date, true).'</br>';
-
 $html_menu_export = enterprise_hook('reporting_print_button_export');
 if ($html_menu_export === ENTERPRISE_NOT_HOOK) {
     $html_menu_export = '';
 }
 
 
-$table->data[0][1] .= '</div>';
-$table->data[0][1] .= $html_menu_export;
+$table2->data[0][2] = '<div><span class="font-title-font">'.__('Set initial date').'</span><br>'.html_print_checkbox_switch('enable_init_date', 1, $enable_init_date, true).'</div><br>';
+$table2->data[0][2] .= '<div style="display:'.$display_to.'" id="string_from"><div><span class="font-title-font">'.__('From').':</span></div>';
+$table2->data[0][2] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' ';
+$table2->data[0][2] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' ';
+$table2->data[0][2] .= '</div><div style="display:'.$display_item.'" id="string_items"><span class="font-title-font">'.__('Items period before').':</span></div>';
+$table2->data[0][2] .= '<div style="display:'.$display_to.'" id="string_to"><span class="font-title-font">'.__('to').':</span></div>';
+$table2->data[0][2] .= html_print_input_text('date', $date, '', 12, 10, true).' ';
+$table2->data[0][2] .= html_print_input_text('time', $time, '', 10, 7, true).' ';
+$table2->data[0][3] = $html_menu_export;
 
 
 
-$table->data[1][1] = '<div>'.__('From').': </div>';
-$table->data[1][1] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' ';
-$table->data[1][1] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' ';
-$table->data[1][2] = '<div style="display:'.$display_item.'" id="string_items">'.__('Items period before').':</div>';
-$table->data[1][2] .= '<div style="display:'.$display_to.'" id="string_to">'.__('to').':</div>';
-$table->data[1][2] .= html_print_input_text('date', $date, '', 12, 10, true).' ';
-$table->data[1][2] .= html_print_input_text('time', $time, '', 10, 7, true).' ';
-
 $searchForm = '<form method="post" action="'.$url.'&pure='.$config['pure'].'" class="mrgn_right_0px">';
-$searchForm .= html_print_table($table, true);
+$searchForm .= html_print_table($table2, true);
 $searchForm .= html_print_input_hidden('id_report', $id_report, true);
 
 $Actionbuttons .= html_print_submit_button(
@@ -354,10 +329,6 @@ for ($i = 0; $i < count($report['contents']); $i++) {
 reporting_html_print_report($report, false, $config['custom_report_info']);
 
 
-// ----------------------------------------------------------------------
-// The rowspan of the first row is only 2 in controls table. Why is used the same code here and in the items??
-$table->rowspan[0][0] = 1;
-
 echo '<div id="loading" class="center">';
 echo html_print_image('images/wait.gif', true, ['border' => '0']);
 echo '<strong>'.__('Loading').'...</strong>';
@@ -387,16 +358,15 @@ $(document).ready (function () {
             secondText: '<?php echo __('Second'); ?>',
             currentText: '<?php echo __('Now'); ?>',
             closeText: '<?php echo __('Close'); ?>'});
-    
+
     $.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
-    
+
     $("#text-date").datepicker({
         dateFormat: "<?php echo DATE_FORMAT_JS; ?>",
         changeMonth: true,
         changeYear: true,
         showAnim: "slideDown"});
-    
-    
+
     $('[id^=text-time_init]').timepicker({
         showSecond: true,
         timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
@@ -407,29 +377,23 @@ $(document).ready (function () {
         secondText: '<?php echo __('Second'); ?>',
         currentText: '<?php echo __('Now'); ?>',
         closeText: '<?php echo __('Close'); ?>'});
-    
+
     $('[id^=text-date_init]').datepicker ({
         dateFormat: "<?php echo DATE_FORMAT_JS; ?>",
         changeMonth: true,
         changeYear: true,
         showAnim: "slideDown"});
-    
-    
-    $("*", "#controls_table-0").css("display", ""); //Re-show the first row of form.
-    
+
     /* Show/hide begin date reports controls */
     $("#checkbox-enable_init_date").click(function() {
         flag = $("#checkbox-enable_init_date").is(':checked');
         if (flag == true) {
-            $("#controls_table-1-1").css("display", "");
-            $("#controls_table-1-2").css("display", "");
             $("#string_to").show();
+            $('#string_from').show();
             $("#string_items").hide();
-        }
-        else {
-            $("#controls_table-1-1").css("display", "none");
-            $("#controls_table-1-2").css("display", "");
+        } else {
             $("#string_to").hide();
+            $('#string_from').hide();
             $("#string_items").show();
         }
     });