#10639 new datepicker style and filters
This commit is contained in:
parent
3ad880cdec
commit
d6df9ed38e
|
@ -201,23 +201,8 @@ class AuditLog extends HTML
|
|||
'name' => 'filter_text',
|
||||
],
|
||||
[
|
||||
'label' => __('Max. hours old'),
|
||||
'type' => 'select',
|
||||
'class' => 'w20px',
|
||||
'select2_enable' => true,
|
||||
'sort' => false,
|
||||
'selected' => 168,
|
||||
'fields' => [
|
||||
24 => __('1 day'),
|
||||
168 => __('7 days'),
|
||||
360 => __('15 days'),
|
||||
744 => __('1 month'),
|
||||
2160 => __('3 months'),
|
||||
4320 => __('6 months'),
|
||||
8760 => __('1 Year'),
|
||||
],
|
||||
'id' => 'filter_period',
|
||||
'name' => 'filter_period',
|
||||
'label' => __('Date'),
|
||||
'type' => 'date_range',
|
||||
],
|
||||
[
|
||||
'label' => __('IP'),
|
||||
|
@ -312,10 +297,35 @@ class AuditLog extends HTML
|
|||
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $this->filterIp);
|
||||
}
|
||||
|
||||
if (empty($this->filterPeriod) === false) {
|
||||
$filter .= sprintf(' AND fecha >= DATE_ADD(NOW(), INTERVAL -%d HOUR)', $this->filterPeriod);
|
||||
// Calculate range dates.
|
||||
$custom_date = $filters['custom_date'];
|
||||
if ($custom_date === '1') {
|
||||
$date_from = ($filters['date_init'].' '.$filters['time_init']);
|
||||
$date_to = ($filters['date_end'].' '.$filters['time_end']);
|
||||
} else if ($custom_date === '2') {
|
||||
$period = ($filters['date_text'] * $filters['date_units']);
|
||||
$date_to = date('Y-m-d H:i:s');
|
||||
$date_from = date('Y-m-d H:i:s', (strtotime($date_to) - $period));
|
||||
} else if (in_array($filters['date'], ['this_week', 'this_month', 'past_week', 'past_month'])) {
|
||||
if ($filters['date'] === 'this_week') {
|
||||
$date_from = date('Y-m-d 00:00:00', strtotime('last monday'));
|
||||
$date_to = date('Y-m-d 23:59:59', strtotime($date_from.' +6 days'));
|
||||
} else if ($filters['date'] === 'this_month') {
|
||||
$date_from = date('Y-m-d 23:59:59', strtotime('first day of this month'));
|
||||
$date_to = date('Y-m-d 00:00:00', strtotime('last day of this month'));
|
||||
} else if ($filters['date'] === 'past_month') {
|
||||
$date_from = date('Y-m-d 00:00:00', strtotime('first day of previous month'));
|
||||
$date_to = date('Y-m-d 23:59:59', strtotime('last day of previous month'));
|
||||
} else if ($filters['date'] === 'past_week') {
|
||||
$date_from = date('Y-m-d 00:00:00', strtotime('monday', strtotime('last week')));
|
||||
$date_to = date('Y-m-d 23:59:59', strtotime('sunday', strtotime('last week')));
|
||||
}
|
||||
} else {
|
||||
$date_to = date('Y-m-d H:i:s');
|
||||
$date_from = date('Y-m-d H:i:s', (strtotime($date_to) - $filters['date']));
|
||||
}
|
||||
|
||||
$filter .= sprintf(' AND fecha BETWEEN "%s" AND "%s"', $date_from, $date_to);
|
||||
$count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tsesion WHERE %s', $filter));
|
||||
|
||||
if ($length !== '-1') {
|
||||
|
|
|
@ -6987,3 +6987,232 @@ function html_print_code_picker(
|
|||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function html_print_select_date_range(
|
||||
$name,
|
||||
$return,
|
||||
$selected=SECONDS_1DAY,
|
||||
$date_init='',
|
||||
$time_init='',
|
||||
$date_end='',
|
||||
$time_end='',
|
||||
$date_text=SECONDS_1DAY,
|
||||
$class=''
|
||||
) {
|
||||
if ($selected === 'custom') {
|
||||
$display_extend = '';
|
||||
$display_range = 'style="display:none"';
|
||||
$display_default = 'style="display:none"';
|
||||
$custom_date = 2;
|
||||
} else if ($selected === 'chose_range') {
|
||||
$display_range = '';
|
||||
$display_default = 'style="display:none"';
|
||||
$display_extend = 'style="display:none"';
|
||||
$custom_date = 1;
|
||||
} else {
|
||||
$display_default = '';
|
||||
$display_range = 'style="display:none"';
|
||||
$display_extend = 'style="display:none"';
|
||||
$custom_date = 0;
|
||||
}
|
||||
|
||||
if ($date_end === '') {
|
||||
$date_end = date('Y/m/d');
|
||||
}
|
||||
|
||||
if ($date_init === '') {
|
||||
$date_init = date('Y/m/d', strtotime($date_end.' -1 days'));
|
||||
}
|
||||
|
||||
if ($time_init === '') {
|
||||
$time_init = date('H:i:s');
|
||||
}
|
||||
|
||||
if ($time_end === '') {
|
||||
$time_end = date('H:i:s');
|
||||
}
|
||||
|
||||
$fields[SECONDS_1DAY] = __('Last 24hr');
|
||||
$fields['this_week'] = __('This week');
|
||||
$fields['this_month'] = __('This month');
|
||||
$fields['past_week'] = __('Past week');
|
||||
$fields['past_month'] = __('Past month');
|
||||
$fields[SECONDS_1WEEK] = __('Last 7 days');
|
||||
$fields[SECONDS_15DAYS] = __('Last 15 days');
|
||||
$fields[SECONDS_1MONTH] = __('Last 30 days');
|
||||
$fields['custom'] = __('Custom');
|
||||
$fields['chose_range'] = __('Chose start/end date period');
|
||||
|
||||
$output = html_print_input_hidden('custom_date', $custom_date, true);
|
||||
$output .= '<div id="'.$name.'_default" class="wauto inline_flex" '.$display_default.'>';
|
||||
$output .= html_print_select(
|
||||
$fields,
|
||||
$name,
|
||||
$selected,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
$class
|
||||
);
|
||||
$output .= '</div>';
|
||||
$output .= '<div id="'.$name.'_range" class="inline_flex" '.$display_range.'>';
|
||||
$table = new stdClass();
|
||||
$table->class = 'table-adv-filter';
|
||||
$table->data[0][0] .= '<div><div><div><span class="font-title-font">'.__('From').':</span></div>';
|
||||
$table->data[0][0] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' ';
|
||||
$table->data[0][0] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' ';
|
||||
$table->data[0][0] .= '</div>';
|
||||
$table->data[0][0] .= '<div><div><span class="font-title-font">'.__('to').':</span></div>';
|
||||
$table->data[0][0] .= html_print_input_text('date_end', $date_end, '', 12, 10, true).' ';
|
||||
$table->data[0][0] .= '<div id="'.$name.'_manual" class="w100p inline_line">';
|
||||
$table->data[0][0] .= html_print_input_text('time_end', $time_end, '', 10, 7, true).' ';
|
||||
$table->data[0][0] .= ' <a href="javascript:">'.html_print_image(
|
||||
'images/logs@svg.svg',
|
||||
true,
|
||||
[
|
||||
'id' => 'back_default',
|
||||
'class' => ' main_menu_icon invert_filter',
|
||||
'alt' => __('List'),
|
||||
'title' => __('List'),
|
||||
'style' => 'width: 18px;',
|
||||
]
|
||||
).'</a>';
|
||||
$table->data[0][0] .= '</div></div>';
|
||||
$output .= html_print_table($table, true);
|
||||
$output .= '</div>';
|
||||
|
||||
$units = [
|
||||
1 => __('seconds'),
|
||||
SECONDS_1MINUTE => __('minutes'),
|
||||
SECONDS_1HOUR => __('hours'),
|
||||
SECONDS_1DAY => __('days'),
|
||||
SECONDS_1WEEK => __('weeks'),
|
||||
SECONDS_1MONTH => __('months'),
|
||||
SECONDS_1YEAR => __('years'),
|
||||
];
|
||||
$output .= '<div id="'.$name.'_extend" class="w100p inline_flex" '.$display_extend.'>';
|
||||
$output .= html_print_input_text($name.'_text', $date_text, '', false, 255, true);
|
||||
$output .= html_print_select(
|
||||
$units,
|
||||
$name.'_units',
|
||||
'1',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
' margin-left: 5px; width: 140px;',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$output .= ' <a href="javascript:">'.html_print_image(
|
||||
'images/logs@svg.svg',
|
||||
true,
|
||||
[
|
||||
'id' => 'back_default_extend',
|
||||
'class' => $name.'_toggler main_menu_icon invert_filter',
|
||||
'alt' => __('List'),
|
||||
'title' => __('List'),
|
||||
'style' => 'width: 18px;margin-bottom: -5px; padding-top: 10px;',
|
||||
]
|
||||
).'</a>';
|
||||
$output .= '</div>';
|
||||
ui_include_time_picker();
|
||||
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
|
||||
$output .= "<script type='text/javascript'>
|
||||
$(document).ready (function () {
|
||||
$('#".$name."').change(function(){
|
||||
if ($(this).val() === 'chose_range') {
|
||||
$('#".$name."_range').show();
|
||||
$('#".$name."_default').hide();
|
||||
$('#".$name."_extend').hide();
|
||||
$('#hidden-custom_date').val('1');
|
||||
} else if ($(this).val() === 'custom') {
|
||||
$('#".$name."_range').hide();
|
||||
$('#".$name."_default').hide();
|
||||
$('#".$name."_extend').show();
|
||||
$('#hidden-custom_date').val('2');
|
||||
}
|
||||
});
|
||||
|
||||
$('#back_default, #back_default_extend').click(function(){
|
||||
display_default();
|
||||
});
|
||||
});
|
||||
|
||||
function display_default(){
|
||||
$('#".$name."_default').show();
|
||||
$('#".$name."_range').hide();
|
||||
$('#".$name."_extend').hide();
|
||||
$('#".$name."').val('".SECONDS_1DAY."').trigger('change');
|
||||
$('#hidden-custom_date').val('0');
|
||||
}
|
||||
|
||||
$('#text-date').datepicker({
|
||||
dateFormat: '".DATE_FORMAT_JS."',
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
showAnim: 'slideDown'
|
||||
});
|
||||
|
||||
$('[id^=text-time_init]').timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '".TIME_FORMAT_JS."',
|
||||
timeOnlyTitle: '".__('Choose time')."',
|
||||
timeText: '".__('Time')."',
|
||||
hourText: '".__('Hour')."',
|
||||
minuteText: '".__('Minute')."',
|
||||
secondText: '".__('Second')."',
|
||||
currentText: '".__('Now')."',
|
||||
closeText: '".__('Close')."'
|
||||
});
|
||||
|
||||
$('[id^=text-date_init]').datepicker ({
|
||||
dateFormat: '".DATE_FORMAT_JS."',
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
showAnim: 'slideDown'
|
||||
});
|
||||
|
||||
$('[id^=text-date_end]').datepicker ({
|
||||
dateFormat: '".DATE_FORMAT_JS."',
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
showAnim: 'slideDown'
|
||||
});
|
||||
|
||||
$('[id^=text-time_end]').timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '".TIME_FORMAT_JS."',
|
||||
timeOnlyTitle: '".__('Choose time')."',
|
||||
timeText: '".__('Time')."',
|
||||
hourText: '".__('Hour')."',
|
||||
minuteText: '".__('Minute')."',
|
||||
secondText: '".__('Second')."',
|
||||
currentText: '".__('Now')."',
|
||||
closeText: '".__('Close')."'
|
||||
});
|
||||
|
||||
</script>";
|
||||
|
||||
if ($return === true) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ function inventory_get_data(
|
|||
$agents_ids,
|
||||
$inventory_module_name,
|
||||
$utimestamp,
|
||||
$period,
|
||||
$inventory_search_string='',
|
||||
$export_csv=false,
|
||||
$return_mode=false,
|
||||
|
@ -97,7 +98,7 @@ function inventory_get_data(
|
|||
|
||||
// Prepare pagination.
|
||||
$url = sprintf(
|
||||
'?sec=estado&sec2=operation/inventory/inventory&agent_id=%s&agent=%s&id_group=%s&export=%s&module_inventory_general_view=%s&search_string=%s&utimestamp=%s&order_by_agent=%s&submit_filter=%d',
|
||||
'?sec=estado&sec2=operation/inventory/inventory&agent_id=%s&agent=%s&id_group=%s&export=%s&module_inventory_general_view=%s&search_string=%s&utimestamp=%s&period=%s&order_by_agent=%s&submit_filter=%d',
|
||||
$pagination_url_parameters['inventory_id_agent'],
|
||||
$pagination_url_parameters['inventory_agent'],
|
||||
$pagination_url_parameters['inventory_id_group'],
|
||||
|
@ -105,6 +106,7 @@ function inventory_get_data(
|
|||
$inventory_module_name,
|
||||
$inventory_search_string,
|
||||
$utimestamp,
|
||||
$period,
|
||||
$order_by_agent,
|
||||
1
|
||||
);
|
||||
|
@ -328,7 +330,7 @@ function inventory_get_data(
|
|||
$timestamp = db_get_value_sql(
|
||||
"SELECT timestamp
|
||||
FROM tagente_datos_inventory
|
||||
WHERE utimestamp = $utimestamp"
|
||||
WHERE utimestamp BETWEEN '".($utimestamp - $period)."' AND '".$utimestamp."'"
|
||||
);
|
||||
} else {
|
||||
$timestamp = db_get_value_sql(
|
||||
|
@ -892,6 +894,14 @@ function get_data_basic_info_sql($params, $count=false)
|
|||
);
|
||||
}
|
||||
|
||||
if ($params['utimestamp'] > 0 && $count === false) {
|
||||
$where .= sprintf(
|
||||
' AND utimestamp BETWEEN %d AND %d',
|
||||
($params['utimestamp'] - $params['period']),
|
||||
$params['utimestamp']
|
||||
);
|
||||
}
|
||||
|
||||
if ($params['order'] > 0) {
|
||||
$str_split = explode(' ', $params['order']);
|
||||
switch ($str_split[0]) {
|
||||
|
|
|
@ -3728,7 +3728,11 @@ function ui_print_datatable(array $parameters)
|
|||
$filter .= '<ul class="datatable_filter content filter_table no_border">';
|
||||
|
||||
foreach ($parameters['form']['inputs'] as $input) {
|
||||
$filter .= html_print_input(($input + ['return' => true]), 'li');
|
||||
if ($input['type'] === 'date_range') {
|
||||
$filter .= '<li><label>'.$input['label'].'</label>'.html_print_select_date_range('date', true).'</li>';
|
||||
} else {
|
||||
$filter .= html_print_input(($input + ['return' => true]), 'li');
|
||||
}
|
||||
}
|
||||
|
||||
$filter .= '</ul>';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -95,11 +95,34 @@
|
|||
.ui-state-default,
|
||||
.ui-widget-content .ui-state-default,
|
||||
.ui-widget-header .ui-state-default {
|
||||
margin-top: 3px;
|
||||
border-bottom: 0;
|
||||
background: transparent;
|
||||
font-weight: normal;
|
||||
color: #555555;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
border: 2px solid #ccc;
|
||||
}
|
||||
.ui-datepicker td,
|
||||
a.ui-state-default,
|
||||
.ui-datepicker td a {
|
||||
width: 30px !important;
|
||||
height: 30px !important;
|
||||
}
|
||||
a.ui-state-default:hover {
|
||||
background-color: #82b92e;
|
||||
}
|
||||
a.ui-state-default > span {
|
||||
text-align: center;
|
||||
margin-top: 2px;
|
||||
}
|
||||
a.ui-state-default > span:hover {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
.ui-datepicker-current-day > a {
|
||||
background-color: #82b92e !important;
|
||||
font-weight: bold !important;
|
||||
border: 2px solid #000 !important;
|
||||
}
|
||||
.ui-corner-all,
|
||||
.ui-corner-top,
|
||||
|
@ -128,13 +151,44 @@
|
|||
#ui-datepicker-div {
|
||||
border-color: #b1b1b1;
|
||||
background: #ffffff;
|
||||
border-radius: 15px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
width: 400px !important;
|
||||
border: 2px solid var(--primary-color);
|
||||
}
|
||||
.ui-datepicker .ui-datepicker-header {
|
||||
position: relative;
|
||||
padding: 0.2em 0;
|
||||
border-radius: 15px 15px 0px 0px;
|
||||
}
|
||||
.ui-datepicker-title,
|
||||
.ui-datepicker-month,
|
||||
.ui-datepicker-year {
|
||||
height: 30px;
|
||||
}
|
||||
.ui-datepicker-month,
|
||||
.ui-datepicker-year {
|
||||
width: 80px !important;
|
||||
}
|
||||
.ui-datepicker-month {
|
||||
margin-left: -10px !important;
|
||||
margin-right: 25px !important;
|
||||
}
|
||||
.ui-widget-header {
|
||||
background: #b1b1b1;
|
||||
background: white;
|
||||
color: #ffffff;
|
||||
}
|
||||
.ui-datepicker-calendar th {
|
||||
background-color: #3f3f3f;
|
||||
background-color: #fff;
|
||||
padding-left: 15px;
|
||||
text-align: initial;
|
||||
}
|
||||
.ui-datepicker-calendar th span {
|
||||
color: #000;
|
||||
}
|
||||
.ui-widget-header {
|
||||
height: 20px !important;
|
||||
}
|
||||
.ui-dialog .ui-widget-header {
|
||||
margin: 3px 3px 0px 3px;
|
||||
|
@ -150,7 +204,10 @@
|
|||
margin: 0px 15px 0px 15px;
|
||||
}
|
||||
.ui-timepicker-div .ui-datepicker-title {
|
||||
color: white;
|
||||
color: black;
|
||||
}
|
||||
.ui-timepicker-div dl {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
.ui-datepicker-buttonpane button {
|
||||
border-color: #b1b1b1;
|
||||
|
@ -175,7 +232,6 @@
|
|||
border: 0px;
|
||||
}
|
||||
|
||||
.ui-state-hover .ui-icon,
|
||||
.ui-state-focus .ui-icon,
|
||||
.ui-button:hover .ui-icon,
|
||||
.ui-button:focus .ui-icon {
|
||||
|
@ -208,35 +264,6 @@ a.ui-button:active,
|
|||
border: none;
|
||||
}
|
||||
|
||||
.ui-state-hover:before,
|
||||
.ui-widget-content .ui-state-hover:before,
|
||||
.ui-widget-header .ui-state-hover:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 25%;
|
||||
bottom: -10%;
|
||||
height: 1px;
|
||||
width: 50%;
|
||||
border-bottom: 4px solid #82b92e;
|
||||
}
|
||||
|
||||
.ui-priority-secondary:hover {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: -5px;
|
||||
width: 100%;
|
||||
border-bottom: 5px solid #82b92e;
|
||||
}
|
||||
|
||||
.ui-priority-primary:hover {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
bottom: -5px;
|
||||
width: 100%;
|
||||
border-bottom: 5px solid #82b92e;
|
||||
}
|
||||
|
||||
.ui-state-active,
|
||||
.ui-widget-content .ui-state-active,
|
||||
.ui-widget-header .ui-state-active {
|
||||
|
@ -289,3 +316,21 @@ input[type="submit"].ui-button-dialog {
|
|||
height: 30px;
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.ui-priority-primary,
|
||||
.ui-priority-secondary {
|
||||
background-color: #fff !important;
|
||||
color: var(--primary-color) !important;
|
||||
border: 2px solid var(--primary-color) !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.ui-timepicker-div > dl dt,
|
||||
.ui-timepicker-div > dl dd {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.ui-timepicker-div > dl dt,
|
||||
.ui_tpicker_time {
|
||||
margin-left: 10px !important;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,54 @@ use PandoraFMS\Enterprise\Metaconsole\Node;
|
|||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_inventory.php';
|
||||
|
||||
// Get different date to search the report.
|
||||
$utimestamp = (int) get_parameter('date_end', 0);
|
||||
$datetime_end = strtotime($utimestamp.' '.$time_end);
|
||||
|
||||
// Calculate new inteval for all reports.
|
||||
$custom_date = get_parameter('custom_date', 0);
|
||||
$date = get_parameter('date', SECONDS_1DAY);
|
||||
$date_text = get_parameter('date_text', SECONDS_1DAY);
|
||||
$date_init_less = (strtotime(date('Y-m-j')) - 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));
|
||||
if ($custom_date === '1') {
|
||||
if ($datetime_init >= $datetime_end) {
|
||||
$datetime_init = $date_init_less;
|
||||
}
|
||||
|
||||
$period = ($datetime_end - $datetime_init);
|
||||
} else if ($custom_date === '2') {
|
||||
$utimestamp = date('Y/m/d H:i:s');
|
||||
$date_start = date('Y/m/d H:i:s', (strtotime($utimestamp) - $date_text));
|
||||
$period = (strtotime($utimestamp) - strtotime($date_start));
|
||||
} else if (in_array($date, ['this_week', 'this_month', 'past_week', 'past_month'])) {
|
||||
if ($date === '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;
|
||||
$utimestamp = $sunday;
|
||||
} else if ($date === 'this_month') {
|
||||
$utimestamp = date('Y/m/d', strtotime('last day of this month'));
|
||||
$first_of_month = date('Y/m/d', strtotime('first day of this month'));
|
||||
$period = (strtotime($utimestamp) - strtotime($first_of_month));
|
||||
} else if ($date === 'past_month') {
|
||||
$utimestamp = date('Y/m/d', strtotime('last day of previous month'));
|
||||
$first_of_month = date('Y/m/d', strtotime('first day of previous month'));
|
||||
$period = (strtotime($utimestamp) - strtotime($first_of_month));
|
||||
} else if ($date === 'past_week') {
|
||||
$utimestamp = date('Y-m-d', strtotime('sunday', strtotime('last week')));
|
||||
$first_of_week = date('Y-m-d', strtotime('monday', strtotime('last week')));
|
||||
$period = (strtotime($utimestamp) - strtotime($first_of_week));
|
||||
}
|
||||
} else {
|
||||
$utimestamp = date('Y/m/d H:i:s');
|
||||
$date_start = date('Y/m/d H:i:s', (strtotime($utimestamp) - $date));
|
||||
$period = (strtotime($utimestamp) - strtotime($date_start));
|
||||
}
|
||||
|
||||
if (is_ajax() === true) {
|
||||
$get_csv_url = (bool) get_parameter('get_csv_url');
|
||||
$get_data_basic_info = (bool) get_parameter('get_data_basic_info');
|
||||
|
@ -43,7 +91,6 @@ if (is_ajax() === true) {
|
|||
// 0 is All groups
|
||||
$inventory_search_string = (string) get_parameter('search_string');
|
||||
$export = (string) get_parameter('export');
|
||||
$utimestamp = (int) get_parameter('utimestamp', 0);
|
||||
$inventory_agent = (string) get_parameter('agent', '');
|
||||
$order_by_agent = (boolean) get_parameter('order_by_agent', 0);
|
||||
|
||||
|
@ -98,6 +145,7 @@ if (is_ajax() === true) {
|
|||
$agents_ids,
|
||||
$inventory_module,
|
||||
$utimestamp,
|
||||
$period,
|
||||
$inventory_search_string,
|
||||
$export,
|
||||
false,
|
||||
|
@ -122,12 +170,14 @@ if (is_ajax() === true) {
|
|||
$id_group = (int) get_parameter('id_group', 0);
|
||||
|
||||
$params = [
|
||||
'search' => $filter['value'],
|
||||
'start' => $start,
|
||||
'length' => $length,
|
||||
'order' => $order,
|
||||
'id_agent' => $id_agent,
|
||||
'id_group' => $id_group,
|
||||
'search' => $filter['value'],
|
||||
'start' => $start,
|
||||
'length' => $length,
|
||||
'order' => $order,
|
||||
'id_agent' => $id_agent,
|
||||
'id_group' => $id_group,
|
||||
'utimestamp' => strtotime($utimestamp),
|
||||
'period' => $period,
|
||||
];
|
||||
|
||||
$data = get_data_basic_info_sql($params);
|
||||
|
@ -677,26 +727,17 @@ $table->data[1][1] = html_print_label_input_block(
|
|||
|
||||
// Date filter. In Metaconsole has not reason for show.
|
||||
if (is_metaconsole() === false) {
|
||||
$dates = inventory_get_dates(
|
||||
$inventory_module,
|
||||
$inventory_id_agent,
|
||||
$inventory_id_group
|
||||
);
|
||||
$table->data[1][2] = html_print_label_input_block(
|
||||
__('Date'),
|
||||
html_print_select(
|
||||
$dates,
|
||||
$table->data[1][2] .= html_print_label_input_block(
|
||||
__('Date').':<br>',
|
||||
html_print_select_date_range(
|
||||
'utimestamp',
|
||||
$utimestamp,
|
||||
'',
|
||||
__('Last'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'width:100%;'
|
||||
get_parameter('utimestamp', SECONDS_1DAY),
|
||||
$date_init,
|
||||
$time_init,
|
||||
date('Y/m/d'),
|
||||
date('H:i:s'),
|
||||
$date_text
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -1301,6 +1342,9 @@ if ($inventory_module !== 'basic') {
|
|||
ui_require_jquery_file('pandora.controls');
|
||||
ui_require_jquery_file('ajaxqueue');
|
||||
ui_require_jquery_file('bgiframe');
|
||||
/*
|
||||
ui_include_time_picker();
|
||||
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');*/
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -1339,6 +1383,51 @@ ui_require_jquery_file('bgiframe');
|
|||
div.firstChild.src = src;
|
||||
});
|
||||
});
|
||||
/*
|
||||
$("#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; ?>',
|
||||
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
||||
timeText: '<?php echo __('Time'); ?>',
|
||||
hourText: '<?php echo __('Hour'); ?>',
|
||||
minuteText: '<?php echo __('Minute'); ?>',
|
||||
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"
|
||||
});
|
||||
|
||||
$('[id^=text-date_end]').datepicker ({
|
||||
dateFormat: "<?php echo DATE_FORMAT_JS; ?>",
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
showAnim: "slideDown"
|
||||
});
|
||||
|
||||
$('[id^=text-time_end]').timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
||||
timeText: '<?php echo __('Time'); ?>',
|
||||
hourText: '<?php echo __('Hour'); ?>',
|
||||
minuteText: '<?php echo __('Minute'); ?>',
|
||||
secondText: '<?php echo __('Second'); ?>',
|
||||
currentText: '<?php echo __('Now'); ?>',
|
||||
closeText: '<?php echo __('Close'); ?>'
|
||||
});*/
|
||||
});
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
|
|
@ -42,19 +42,46 @@ if (! check_acl($config['id_user'], 0, 'AR')) {
|
|||
// Include JS timepicker.
|
||||
ui_include_time_picker();
|
||||
|
||||
// Query params and other initializations.
|
||||
$time_greater = get_parameter('time_greater', date(TIME_FORMAT));
|
||||
$date_greater = get_parameter('date_greater', date(DATE_FORMAT));
|
||||
$utimestamp_greater = strtotime($date_greater.' '.$time_greater);
|
||||
$is_period = (bool) get_parameter('is_period', false);
|
||||
$period = (int) get_parameter('period', SECONDS_1HOUR);
|
||||
$time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($utimestamp_greater - $period)));
|
||||
$date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($utimestamp_greater - $period)));
|
||||
$utimestamp_lower = ($is_period) ? ($utimestamp_greater - $period) : strtotime($date_lower.' '.$time_lower);
|
||||
if (!$is_period) {
|
||||
$period = ($utimestamp_greater - $utimestamp_lower);
|
||||
|
||||
// Calculate range dates.
|
||||
$custom_date = get_parameter('custom_date', '0');
|
||||
$date = get_parameter('date', SECONDS_1DAY);
|
||||
if ($custom_date === '1') {
|
||||
$date_init = get_parameter('date_init');
|
||||
$time_init = get_parameter('time_init');
|
||||
$date_end = get_parameter('date_end');
|
||||
$time_end = get_parameter('time_end');
|
||||
$date_from = strtotime($date_init.' '.$time_init);
|
||||
$date_to = strtotime($date_end.' '.$time_end);
|
||||
} else if ($custom_date === '2') {
|
||||
$date_text = get_parameter('date_text');
|
||||
$date_units = get_parameter('date_units');
|
||||
$period = ($date_text * $date_units);
|
||||
$date_to = strtotime(date('Y-m-d H:i:s'));
|
||||
$date_from = (strtotime($date_to) - $period);
|
||||
} else if (in_array($date, ['this_week', 'this_month', 'past_week', 'past_month'])) {
|
||||
if ($date === 'this_week') {
|
||||
$date_from = strtotime('last monday');
|
||||
$date_to = strtotime($date_from.' +6 days');
|
||||
} else if ($date === 'this_month') {
|
||||
$date_from = strtotime('first day of this month');
|
||||
$date_to = strtotime('last day of this month');
|
||||
} else if ($date === 'past_month') {
|
||||
$date_from = strtotime('first day of previous month');
|
||||
$date_to = strtotime('last day of previous month');
|
||||
} else if ($date === 'past_week') {
|
||||
$date_from = strtotime('monday', strtotime('last week'));
|
||||
$date_to = strtotime('sunday', strtotime('last week'));
|
||||
}
|
||||
} else {
|
||||
$date_to = strtotime(date('Y-m-d H:i:s'));
|
||||
$date_from = ($date_to - $date);
|
||||
}
|
||||
|
||||
// Query params and other initializations.
|
||||
$utimestamp_greater = $date_to;
|
||||
$utimestamp_lower = $date_from;
|
||||
|
||||
$top = (int) get_parameter('top', 10);
|
||||
$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', '');
|
||||
if (is_numeric($main_value) && !in_array($action, ['udp', 'tcp'])) {
|
||||
|
@ -66,9 +93,6 @@ if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) {
|
|||
$order_by = 'bytes';
|
||||
}
|
||||
|
||||
$style_end = ($is_period) ? 'display: none;' : '';
|
||||
$style_period = ($is_period) ? '' : 'display: none;';
|
||||
|
||||
// Build the table.
|
||||
$table = new stdClass();
|
||||
$table->class = 'filter-table-adv';
|
||||
|
@ -112,83 +136,7 @@ $table->data[0][] = html_print_label_input_block(
|
|||
|
||||
$table->data[1][] = html_print_label_input_block(
|
||||
__('Start date'),
|
||||
html_print_div(
|
||||
[
|
||||
'id' => 'end_date_container',
|
||||
'content' => html_print_input_text(
|
||||
'date_lower',
|
||||
$date_lower,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
).html_print_input_text(
|
||||
'time_lower',
|
||||
$time_lower,
|
||||
'',
|
||||
7,
|
||||
8,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
).html_print_div(
|
||||
[
|
||||
'id' => 'period_container',
|
||||
'style' => 'display: none;',
|
||||
'content' => html_print_label_input_block(
|
||||
'',
|
||||
html_print_extended_select_for_time(
|
||||
'period',
|
||||
$period,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
false,
|
||||
true
|
||||
),
|
||||
),
|
||||
],
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
$table->data[1][] = html_print_label_input_block(
|
||||
__('End date'),
|
||||
html_print_div(
|
||||
[
|
||||
'id' => '',
|
||||
'class' => '',
|
||||
'content' => html_print_input_text(
|
||||
'date_greater',
|
||||
$date_greater,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
).html_print_input_text(
|
||||
'time_greater',
|
||||
$time_greater,
|
||||
'',
|
||||
7,
|
||||
8,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
$table->data[2][] = html_print_label_input_block(
|
||||
__('Defined period'),
|
||||
html_print_checkbox_switch(
|
||||
'is_period',
|
||||
1,
|
||||
($is_period === true) ? 1 : 0,
|
||||
true,
|
||||
false,
|
||||
'network_report_click_period(event)'
|
||||
)
|
||||
html_print_select_date_range('date', true)
|
||||
);
|
||||
|
||||
echo '<form method="post">';
|
||||
|
@ -254,8 +202,6 @@ $data = netflow_get_top_summary(
|
|||
$hidden_main_link = [
|
||||
'time_greater' => $time_greater,
|
||||
'date_greater' => $date_greater,
|
||||
'is_period' => $is_period,
|
||||
'period' => $period,
|
||||
'time_lower' => $time_lower,
|
||||
'date_lower' => $date_lower,
|
||||
'top' => $top,
|
||||
|
@ -466,10 +412,4 @@ $("#text-time_lower, #text-time_greater").timepicker({
|
|||
$("#text-date_lower, #text-date_greater").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
|
||||
function network_report_click_period(event) {
|
||||
var is_period = document.getElementById(event.target.id).checked;
|
||||
|
||||
document.getElementById('period_container').style.display = !is_period ? 'none' : 'block';
|
||||
document.getElementById('end_date_container').style.display = is_period ? 'none' : 'block';
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -43,28 +43,58 @@ if (!reporting_user_can_see_report($id_report)) {
|
|||
exit;
|
||||
}
|
||||
|
||||
// Get different date to search the report.
|
||||
$date = (string) get_parameter('date', date(DATE_FORMAT));
|
||||
$time = (string) get_parameter('time', date(TIME_FORMAT));
|
||||
|
||||
$datetime = strtotime($date.' '.$time);
|
||||
|
||||
// Calculations in order to modify init date of the report
|
||||
// Calculations in order to modify init date of the report.
|
||||
$date_init_less = (strtotime(date('Y-m-j')) - 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);
|
||||
$enable_init_date = get_parameter('enable_init_date', 0);
|
||||
$pure = (int) get_parameter('pure', 0);
|
||||
|
||||
$period = null;
|
||||
// Calculate new inteval for all reports
|
||||
if ($enable_init_date) {
|
||||
if ($datetime_init >= $datetime) {
|
||||
// Get different date to search the report.
|
||||
$date_end = (string) get_parameter('date_end', date(DATE_FORMAT));
|
||||
$time_end = (string) get_parameter('time_end', date(TIME_FORMAT));
|
||||
$datetime_end = strtotime($date_end.' '.$time_end);
|
||||
|
||||
// Calculate new inteval for all reports.
|
||||
$custom_date = get_parameter('custom_date', 0);
|
||||
$date = get_parameter('date', SECONDS_1DAY);
|
||||
$date_text = get_parameter('date_text', SECONDS_1DAY);
|
||||
if ($custom_date === '1') {
|
||||
if ($datetime_init >= $datetime_end) {
|
||||
$datetime_init = $date_init_less;
|
||||
}
|
||||
|
||||
$period = ($datetime - $datetime_init);
|
||||
$period = ($datetime_end - $datetime_init);
|
||||
} else if ($custom_date === '2') {
|
||||
$date_end = date('Y/m/d H:i:s');
|
||||
$date_start = date('Y/m/d H:i:s', (strtotime($date_end) - $date_text));
|
||||
$period = (strtotime($date_end) - strtotime($date_start));
|
||||
} else if (in_array($date, ['this_week', 'this_month', 'past_week', 'past_month'])) {
|
||||
if ($date === '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 ($date === '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'));
|
||||
$period = (strtotime($date_end) - strtotime($first_of_month));
|
||||
} else if ($date === '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'));
|
||||
$period = (strtotime($date_end) - strtotime($first_of_month));
|
||||
} else if ($date === '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')));
|
||||
$period = (strtotime($date_end) - strtotime($first_of_week));
|
||||
}
|
||||
} else {
|
||||
$date_end = date('Y/m/d H:i:s');
|
||||
$date_start = date('Y/m/d H:i:s', (strtotime($date_end) - $date));
|
||||
$period = (strtotime($date_end) - strtotime($date_start));
|
||||
}
|
||||
|
||||
// Shchedule report email.
|
||||
|
@ -242,7 +272,7 @@ $table2->styleTable = 'border:none';
|
|||
|
||||
if (defined('METACONSOLE')) {
|
||||
$table2->width = '100%';
|
||||
$table2->class = 'databox filters';
|
||||
$table2->class = 'databox filters filter-table-adv';
|
||||
|
||||
$table2->head[0] = __('View Report');
|
||||
$table2->head_colspan[0] = 5;
|
||||
|
@ -264,14 +294,10 @@ if ($html_menu_export === ENTERPRISE_NOT_HOOK) {
|
|||
}
|
||||
|
||||
|
||||
$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][2] .= html_print_label_input_block(
|
||||
__('Date').':<br>',
|
||||
html_print_select_date_range('date', true, get_parameter('date', SECONDS_1DAY), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text)
|
||||
);
|
||||
$table2->data[0][3] = $html_menu_export;
|
||||
|
||||
|
||||
|
@ -313,7 +339,7 @@ ui_toggle(
|
|||
);
|
||||
// ------------------------ END FORM ------------------------------------
|
||||
if ($enable_init_date) {
|
||||
if ($datetime_init > $datetime) {
|
||||
if ($datetime_init > $datetime_end) {
|
||||
ui_print_error_message(
|
||||
__('Invalid date selected. Initial date must be before end date.')
|
||||
);
|
||||
|
@ -323,7 +349,7 @@ if ($enable_init_date) {
|
|||
$report = reporting_make_reporting_data(
|
||||
null,
|
||||
$id_report,
|
||||
$date,
|
||||
$date_end,
|
||||
$time,
|
||||
$period,
|
||||
'dinamic'
|
||||
|
@ -367,28 +393,6 @@ $(document).ready (function () {
|
|||
|
||||
$.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; ?>',
|
||||
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
||||
timeText: '<?php echo __('Time'); ?>',
|
||||
hourText: '<?php echo __('Hour'); ?>',
|
||||
minuteText: '<?php echo __('Minute'); ?>',
|
||||
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"});
|
||||
|
||||
/* Show/hide begin date reports controls */
|
||||
$("#checkbox-enable_init_date").click(function() {
|
||||
|
@ -408,8 +412,4 @@ $(document).ready (function () {
|
|||
</script>
|
||||
|
||||
<?php
|
||||
if ($datetime === false || $datetime == -1) {
|
||||
ui_print_error_message(__('Invalid date selected'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue