From d8e0df19122f2b12f84029e09beab960066ab40f Mon Sep 17 00:00:00 2001
From: Daniel Cebrian <daniel.cebrian@pandorafms.com>
Date: Wed, 6 Sep 2023 08:52:46 +0200
Subject: [PATCH 1/3] #10983 new function for get date parameter and added
 parent date in dashboard

---
 pandora_console/extras/mr/66.sql              |  5 ++
 pandora_console/include/functions.php         | 64 +++++++++++++++++++
 pandora_console/include/functions_html.php    | 14 ++++
 .../include/lib/Dashboard/Manager.php         | 11 ++++
 .../include/lib/Dashboard/Widget.php          | 51 +++++++++++++++
 .../lib/Dashboard/Widgets/BlockHistogram.php  |  3 +
 .../lib/Dashboard/Widgets/single_graph.php    |  4 ++
 pandora_console/pandoradb.sql                 |  3 +
 .../views/dashboard/formDashboard.php         | 39 +++++++++++
 9 files changed, 194 insertions(+)

diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql
index 8161c4c2b6..a30bcb4565 100644
--- a/pandora_console/extras/mr/66.sql
+++ b/pandora_console/extras/mr/66.sql
@@ -44,4 +44,9 @@ ADD COLUMN `time_init` VARCHAR(45) NULL AFTER `date_init`,
 ADD COLUMN `date_end` VARCHAR(45) NULL AFTER `time_init`,
 ADD COLUMN `time_end` VARCHAR(45) NULL AFTER `date_end`;
 
+ALTER TABLE `tdashboard`
+ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`,
+ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`,
+ADD COLUMN `date_to` INT NOT NULL DEFAULT 0 AFTER `date_from`;
+
 COMMIT;
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 0895325ef5..0a166a28d2 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -990,6 +990,70 @@ function get_parameter($name, $default='')
 }
 
 
+function get_parameter_date($name, $default='', $date_format='Y/m/d')
+{
+    $date_end = get_parameter('date_end', 0);
+    $time_end = get_parameter('time_end');
+    $datetime_end = strtotime($date_end.' '.$time_end);
+
+    $custom_date = get_parameter('custom_date', 0);
+    $range = get_parameter('range', SECONDS_1DAY);
+    $date_text = get_parameter('range_text', SECONDS_1DAY);
+    $date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY);
+    $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
+    $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
+    $datetime_init = strtotime($date_init.' '.$time_init);
+    if ($custom_date === '1') {
+        if ($datetime_init >= $datetime_end) {
+            $datetime_init = $date_init_less;
+        }
+
+        $date_init = date('Y/m/d H:i:s', $datetime_init);
+        $date_end = date('Y/m/d H:i:s', $datetime_end);
+        $period = ($datetime_end - $datetime_init);
+    } else if ($custom_date === '2') {
+        $date_units = get_parameter('range_units');
+        $date_end = date('Y/m/d H:i:s');
+        $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units)));
+        $period = (strtotime($date_end) - strtotime($date_init));
+    } else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) {
+        if ($range === 'this_week') {
+            $monday = date('Y/m/d', strtotime('last monday'));
+
+            $sunday = date('Y/m/d', strtotime($monday.' +6 days'));
+            $period = (strtotime($sunday) - strtotime($monday));
+            $date_init = $monday;
+            $date_end = $sunday;
+        } else if ($range === 'this_month') {
+            $date_end = date('Y/m/d', strtotime('last day of this month'));
+            $first_of_month = date('Y/m/d', strtotime('first day of this month'));
+            $date_init = $first_of_month;
+            $period = (strtotime($date_end) - strtotime($first_of_month));
+        } else if ($range === 'past_month') {
+            $date_end = date('Y/m/d', strtotime('last day of previous month'));
+            $first_of_month = date('Y/m/d', strtotime('first day of previous month'));
+            $date_init = $first_of_month;
+            $period = (strtotime($date_end) - strtotime($first_of_month));
+        } else if ($range === 'past_week') {
+            $date_end = date('Y/m/d', strtotime('sunday', strtotime('last week')));
+            $first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week')));
+            $date_init = $first_of_week;
+            $period = (strtotime($date_end) - strtotime($first_of_week));
+        }
+    } else {
+        $date_end = date('Y/m/d H:i:s');
+        $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
+        $period = (strtotime($date_end) - strtotime($date_init));
+    }
+
+    return [
+        'date_init' => date($date_format, strtotime($date_init)),
+        'date_end'  => date($date_format, strtotime($date_end)),
+        'period'    => $period,
+    ];
+}
+
+
 /**
  * Get a parameter from a get request.
  *
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 3d8eb231b9..1f33023bf9 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -6280,6 +6280,20 @@ function html_print_input($data, $wrapper='div', $input_only=false)
             );
         break;
 
+        case 'date_range':
+            $output .= html_print_select_date_range(
+                $data['name'],
+                true,
+                (isset($data['selected']) === true) ? $data['selected'] : SECONDS_1DAY,
+                (isset($data['date_init']) === true) ? $data['date_init'] : '',
+                (isset($data['time_init']) === true) ? $data['time_init'] : '',
+                (isset($data['date_end']) === true) ? $data['date_end'] : '',
+                (isset($data['time_end']) === true) ? $data['time_end'] : '',
+                (isset($data['date_text']) === true) ? $data['date_text'] : SECONDS_1DAY,
+                (isset($data['class']) === true) ? $data['class'] : 'w100p',
+            );
+        break;
+
         default:
             // Ignore.
         break;
diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php
index 40b6d2d1a0..10ab96986c 100644
--- a/pandora_console/include/lib/Dashboard/Manager.php
+++ b/pandora_console/include/lib/Dashboard/Manager.php
@@ -458,6 +458,12 @@ class Manager implements PublicLogin
             $this->publicLink
         );
 
+        if ((bool) $this->dashboardFields['date_range'] === true) {
+            $dateFrom = $this->dashboardFields['date_from'];
+            $dateTo = $this->dashboardFields['date_to'];
+            $instance->setDateRange($dateFrom, $dateTo);
+        }
+
         return $instance;
     }
 
@@ -1015,6 +1021,8 @@ class Manager implements PublicLogin
         $id_group = \get_parameter('id_group');
         $slideshow = \get_parameter_switch('slideshow');
         $favourite = \get_parameter_switch('favourite');
+        $dateRange = \get_parameter_switch('date_range');
+        $dateData = \get_parameter_date('range', '', 'U');
 
         $id_user = (empty($private) === false) ? $config['id_user'] : '';
 
@@ -1024,6 +1032,9 @@ class Manager implements PublicLogin
             'id_group'        => $id_group,
             'cells_slideshow' => $slideshow,
             'active'          => $favourite,
+            'date_range'      => $dateRange,
+            'date_from'       => $dateData['date_init'],
+            'date_to'         => $dateData['date_end'],
         ];
 
         if ($this->dashboardId === 0) {
diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php
index b9364fcd31..acd9f4c94f 100644
--- a/pandora_console/include/lib/Dashboard/Widget.php
+++ b/pandora_console/include/lib/Dashboard/Widget.php
@@ -51,6 +51,20 @@ class Widget
      */
     private $showSelectNodeMeta;
 
+    /**
+     * Date from init for filter widget.
+     *
+     * @var integer
+     */
+    private $dateFrom;
+
+    /**
+     * Date from end for filter widget.
+     *
+     * @var integer
+     */
+    private $dateTo;
+
 
     /**
      * Contructor widget.
@@ -804,4 +818,41 @@ class Widget
     }
 
 
+    /**
+     * Set the date range of parent configuration.
+     *
+     * @param integer $dateFrom Date from init for filter widget.
+     * @param integer $dateTo   Date from end for filter widget.
+     *
+     * @return void
+     */
+    public function setDateRange(int $dateFrom, int $dateTo)
+    {
+        $this->dateFrom = $dateFrom;
+        $this->dateTo = $dateTo;
+    }
+
+
+    public function getDateFrom()
+    {
+        return $this->dateFrom;
+    }
+
+
+    public function getDateTo()
+    {
+        return $this->dateTo;
+    }
+
+
+    public function getPeriod():mixed
+    {
+        if (empty($this->dateFrom) === false && empty($this->dateTo) === false) {
+            return ($this->dateTo - $this->dateFrom);
+        } else {
+            return null;
+        }
+    }
+
+
 }
diff --git a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php
index a3ff215c76..1484823518 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php
@@ -520,6 +520,9 @@ class BlockHistogram extends Widget
         global $config;
 
         $size = parent::getSize();
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
 
         // Desactive scroll bars only this item.
         $id_agent = $data['agent_id'];
diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
index 72ad55309b..013faf1e67 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
@@ -399,6 +399,10 @@ class SingleGraphWidget extends Widget
         $module_name = \modules_get_agentmodule_name($this->values['moduleId']);
         $units_name = \modules_get_unit($this->values['moduleId']);
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         $trickHight = 0;
         if ($this->values['showLegend'] === 1) {
             // Needed for legend.
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index b50a5ba149..a92eb3b2c5 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -2665,6 +2665,9 @@ CREATE TABLE IF NOT EXISTS `tdashboard` (
   `active` TINYINT NOT NULL DEFAULT 0,
   `cells` INT UNSIGNED DEFAULT 0,
   `cells_slideshow` TINYINT NOT NULL DEFAULT 0,
+  `date_range` TINYINT NOT NULL DEFAULT 0,
+  `date_from` INT NOT NULL DEFAULT 0,
+  `date_to` INT NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
 
diff --git a/pandora_console/views/dashboard/formDashboard.php b/pandora_console/views/dashboard/formDashboard.php
index c36df6cf06..fafacd583d 100644
--- a/pandora_console/views/dashboard/formDashboard.php
+++ b/pandora_console/views/dashboard/formDashboard.php
@@ -102,6 +102,31 @@ $inputs = [
             ],
         ],
     ],
+    [
+        'label'     => __('Date range'),
+        'arguments' => [
+            'name'     => 'date_range',
+            'id'       => 'date_range',
+            'type'     => 'switch',
+            'value'    => $arrayDashboard['date_range'],
+            'onchange' => 'handle_date_range(this)',
+        ],
+    ],
+    [
+        'label'     => __('Select range'),
+        'style'     => 'display: none;',
+        'class'     => 'row_date_range',
+        'arguments' => [
+            'name'      => 'range',
+            'id'        => 'range',
+            'selected'  => ($arrayDashboard['date_to'] - $arrayDashboard['date_from']),
+            'type'      => 'date_range',
+            'date_init' => $arrayDashboard['date_from'],
+            'time_init' => $arrayDashboard['date_from'],
+            'date_end'  => $arrayDashboard['date_to'],
+            'time_end'  => $arrayDashboard['date_to'],
+        ],
+    ],
     [
         'block_id'      => 'private',
         'direct'        => 1,
@@ -135,3 +160,17 @@ HTML::printForm(
         'inputs' => $inputs,
     ]
 );
+
+?>
+
+<script>
+function handle_date_range(element){
+    if(element.checked) {
+        $(".row_date_range").show();
+    } else {
+        $(".row_date_range").hide();
+    }
+}
+var date_range = $("#date_range")[0];
+handle_date_range(date_range);
+</script>
\ No newline at end of file

From dbf315e4079fd9359b7b8f87560ad1a36c46c5fb Mon Sep 17 00:00:00 2001
From: Daniel Cebrian <daniel.cebrian@pandorafms.com>
Date: Mon, 23 Oct 2023 14:48:34 +0200
Subject: [PATCH 2/3] #10983 revised widgets with intervals

---
 .../lib/Dashboard/Widgets/BasicChart.php      |  4 ++++
 .../lib/Dashboard/Widgets/DataMatrix.php      |  4 ++++
 .../lib/Dashboard/Widgets/custom_graph.php    |  4 ++++
 .../Widgets/graph_module_histogram.php        |  4 ++++
 .../include/lib/Dashboard/Widgets/netflow.php |  6 +++++
 .../Dashboard/Widgets/security_hardening.php  |  6 +++++
 .../lib/Dashboard/Widgets/single_graph.php    |  4 ++++
 .../include/lib/Dashboard/Widgets/top_n.php   |  4 ++++
 .../views/dashboard/formDashboard.php         | 23 +++++++++++++++----
 9 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php
index c3b9ddf9ad..a140d7fcb4 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php
@@ -637,6 +637,10 @@ class BasicChart extends Widget
             $color_status = $this->values['colorValue'];
         }
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         $params = [
             'agent_module_id'    => $this->values['moduleId'],
             'period'             => $this->values['period'],
diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php
index be38c31bb4..770a3152fe 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php
@@ -473,6 +473,10 @@ class DataMatrix extends Widget
             return $output;
         }
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         if (is_metaconsole() === true) {
             $modules_nodes = array_reduce(
                 $this->values['moduleDataMatrix'],
diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php
index 377ca145a0..4cb4734105 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php
@@ -472,6 +472,10 @@ class CustomGraphWidget extends Widget
 
         $size = parent::getSize();
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         switch ($this->values['type']) {
             case CUSTOM_GRAPH_STACKED_LINE:
             case CUSTOM_GRAPH_STACKED_AREA:
diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php
index b0382ba273..38967c2e47 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php
@@ -302,6 +302,10 @@ class GraphModuleHistogramWidget extends Widget
             $values['period'] = SECONDS_1DAY;
         }
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         if (isset($values['sizeLabel']) === false) {
             $values['sizeLabel'] = 30;
         }
diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php
index 13a15bf6a0..6c0aa76eca 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/netflow.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php
@@ -309,6 +309,12 @@ class Netflow extends Widget
 
         $start_date = (time() - $this->values['period']);
         $end_date = time();
+
+        if (empty(parent::getPeriod()) === false) {
+            $start_date = parent::getDateFrom();
+            $end_date = parent::getDateTo();
+        }
+
         if ($this->values['chart_type'] === 'usage_map') {
             $map_data = netflow_build_map_data(
                 $start_date,
diff --git a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php
index 2c936728ed..14afbcfb20 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php
@@ -134,6 +134,7 @@ class SecurityHardening extends Widget
 
         // Includes.
         include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php';
+        include_once $config['homedir'].'/include/graphs/fgraph.php';
         // WARNING: Do not edit. This chunk must be in the constructor.
         parent::__construct(
             $cellId,
@@ -325,6 +326,11 @@ class SecurityHardening extends Widget
         $id_groups = $this->checkAcl($values['group']);
         $output .= '<b>'.$this->elements[$data_type].'</b>';
 
+        if (empty(parent::getPeriod()) === false) {
+            $values['date_init'] = parent::getDateFrom();
+            $values['date_end'] = parent::getDateTo();
+        }
+
         switch ($data_type) {
             case 'top_n_agents_sh':
                 $output .= $this->loadTopNAgentsSh($id_groups, $values['limit']);
diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
index 236b19c554..280bf3226f 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
@@ -300,6 +300,10 @@ class SingleGraphWidget extends Widget
             $values['period'] = SECONDS_1DAY;
         }
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         if (isset($values['showLegend']) === false) {
             $values['showLegend'] = 1;
         }
diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php
index 5a603501c0..f732f8b264 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php
@@ -374,6 +374,10 @@ class TopNWidget extends Widget
 
         $size = parent::getSize();
 
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
+
         $quantity = $this->values['quantity'];
         $period = $this->values['period'];
 
diff --git a/pandora_console/views/dashboard/formDashboard.php b/pandora_console/views/dashboard/formDashboard.php
index fafacd583d..be21a3142e 100644
--- a/pandora_console/views/dashboard/formDashboard.php
+++ b/pandora_console/views/dashboard/formDashboard.php
@@ -119,12 +119,12 @@ $inputs = [
         'arguments' => [
             'name'      => 'range',
             'id'        => 'range',
-            'selected'  => ($arrayDashboard['date_to'] - $arrayDashboard['date_from']),
+            'selected'  => ($arrayDashboard['date_from'] === '0' && $arrayDashboard['date_to'] === '0') ? 300 : 'chose_range',
             'type'      => 'date_range',
-            'date_init' => $arrayDashboard['date_from'],
-            'time_init' => $arrayDashboard['date_from'],
-            'date_end'  => $arrayDashboard['date_to'],
-            'time_end'  => $arrayDashboard['date_to'],
+            'date_init' => date('Y/m/d', $arrayDashboard['date_from']),
+            'time_init' => date('H:i:s', $arrayDashboard['date_from']),
+            'date_end'  => date('Y/m/d', $arrayDashboard['date_to']),
+            'time_end'  => date('H:i:s', $arrayDashboard['date_to']),
         ],
     ],
     [
@@ -167,6 +167,19 @@ HTML::printForm(
 function handle_date_range(element){
     if(element.checked) {
         $(".row_date_range").show();
+        var def_state_range = $('#range_range').is(':visible');
+        var def_state_default = $('#range_default').is(':visible');
+        var def_state_extend = $('#range_extend').is(':visible');
+        if (
+            def_state_range === false
+            && def_state_default === false
+            && def_state_extend === false
+            && $('#range').val() !== 'chose_range'
+        ) {
+            $('#range_default').show();
+        } else if ($('#range').val() === 'chose_range') {
+            $('#range_range').show();
+        }
     } else {
         $(".row_date_range").hide();
     }

From a23bc00d171ce805393c078a8cf2008d555cb682 Mon Sep 17 00:00:00 2001
From: Daniel Cebrian <daniel.cebrian@pandorafms.com>
Date: Mon, 23 Oct 2023 17:17:22 +0200
Subject: [PATCH 3/3] #10983 added control time in graphs

---
 .../include/lib/Dashboard/Widgets/single_graph.php            | 4 ----
 pandora_console/include/lib/Dashboard/Widgets/sla_percent.php | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
index 280bf3226f..236b19c554 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php
@@ -300,10 +300,6 @@ class SingleGraphWidget extends Widget
             $values['period'] = SECONDS_1DAY;
         }
 
-        if (empty(parent::getPeriod()) === false) {
-            $this->values['period'] = parent::getPeriod();
-        }
-
         if (isset($values['showLegend']) === false) {
             $values['showLegend'] = 1;
         }
diff --git a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php
index 4dfefbf292..f3c7fb826e 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php
@@ -459,6 +459,9 @@ class SLAPercentWidget extends Widget
         global $config;
 
         $size = parent::getSize();
+        if (empty(parent::getPeriod()) === false) {
+            $this->values['period'] = parent::getPeriod();
+        }
 
         $output .= '';
         $id_agent = $this->values['agentId'];