Merge branch 'ent-6753-consistencia-en-el-selector-de-grupos' into 'develop'

group selector updates for report, required

See merge request artica/pandorafms!3763
This commit is contained in:
Daniel Rodriguez 2021-03-18 16:05:16 +00:00
commit 8eb06d8adc
8 changed files with 144 additions and 74 deletions

View File

@ -132,7 +132,7 @@ if ($edit_container) {
$id_parent = get_parameter('id_parent', 0);
$description = io_safe_input(get_parameter('description', ''));
$id_group = get_parameter('container_id_group', 0);
} else {
} else if ((bool) $id_container !== false) {
$tcontainer = db_get_row_sql('SELECT * FROM tcontainer WHERE id_container = '.$id_container);
$name = $tcontainer['name'];
$id_parent = $tcontainer['parent'];
@ -142,13 +142,21 @@ if ($edit_container) {
}
if ($add_container) {
$values = [
'name' => $name,
'description' => $description,
'parent' => $id_parent,
'id_group' => $id_group,
];
$id_container = db_process_sql_insert('tcontainer', $values);
if ((bool) $name !== false) {
$values = [
'name' => $name,
'description' => $description,
'parent' => $id_parent,
'id_group' => $id_group,
];
$id_container = db_process_sql_insert('tcontainer', $values);
} else {
$error = ui_print_error_message(
__('Container name is missing.'),
'',
true
);
}
}
if ($update_container) {
@ -195,6 +203,9 @@ ui_print_page_header(
if ($add_container) {
ui_print_result_message($id_container, __('Container stored successfully'), __('There was a problem storing container'));
if (empty($error) === false) {
echo $error;
}
}
if ($update_container) {
@ -214,6 +225,8 @@ if ($id_container === '1') {
echo "<td class='datos w30p'><input type='text' name='name' size='30' disabled='1'";
} else {
echo "<td class='datos w30p'><input type='text' name='name' size='30' ";
// Using latest style...
echo ' required ';
}
if ($edit_container) {
@ -230,21 +243,31 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
echo "<td class='w10p'><b>".__('Group').'</b></td><td>';
echo '<div class="w250px">';
if ($id_container === '1') {
echo html_print_select_groups($config['id_user'], '', $return_all_groups, 'container_id_group', $id_group, '', '', '', true, false, true, '', true);
} else {
echo html_print_select_groups($config['id_user'], '', $return_all_groups, 'container_id_group', $id_group, '', '', '', true, false, true, '', false);
}
echo html_print_input(
[
'type' => 'select_groups',
'id_user' => $config['id_user'],
'privilege' => 'RW',
'returnAllGroup' => $return_all_groups,
'name' => 'container_id_group',
'selected' => $id_group,
'script' => '',
'nothing' => '',
'nothing_value' => '',
'return' => false,
'required' => true,
'disabled' => ($id_container === '1'),
]
);
echo '</div>';
echo '</td></tr>';
echo '<tr>';
echo "<td class='datos2'><b>".__('Description').'</b></td>';
if ($id_container === '1') {
echo "<td class='datos2' colspan=3><textarea name='description' class='height_45px' cols=95 rows=2 disabled>";
echo "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=95 rows=2 disabled>";
} else {
echo "<td class='datos2' colspan=3><textarea name='description' class='height_45px' cols=95 rows=2>";
echo "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=95 rows=2>";
}
if ($edit_container) {
@ -400,8 +423,8 @@ if ($edit_container) {
$single_table .= '</td>';
$single_table .= '</tr>';
$single_table .= "<tr id='row_type_graphs' class='datos'>";
$single_table .= "<td class='bolder'>";
$single_table .= "<tr id='row_type_graphs' style='' class='datos'>";
$single_table .= "<td style='font-weight:bold;'>";
$single_table .= __('Type of graph');
$single_table .= '</td>';
$single_table .= '<td>';
@ -409,8 +432,8 @@ if ($edit_container) {
$single_table .= '</td>';
$single_table .= '</tr>';
$single_table .= "<tr id='row_fullscale' class='datos'>";
$single_table .= "<td class='bolder'>";
$single_table .= "<tr id='row_fullscale' style='' class='datos'>";
$single_table .= "<td style='font-weight:bold;'>";
$single_table .= __('Show full scale graph (TIP)').ui_print_help_tip('This option may cause performance issues', true);
$single_table .= '</td>';
$single_table .= '<td>';
@ -421,8 +444,8 @@ if ($edit_container) {
$single_table .= '<tr>';
$single_table .= '<td >';
$single_table .= '</td>';
$single_table .= "<td class='right'>";
$single_table .= "<input type=submit name='add_single' class='sub add right' value='".__('Add item')."'>";
$single_table .= "<td style='float:right;'>";
$single_table .= "<input style='float:right;' type=submit name='add_single' class='sub add' value='".__('Add item')."'>";
$single_table .= '</td>';
$single_table .= '</tr>';
$single_table .= '</table>';
@ -475,7 +498,7 @@ if ($edit_container) {
$data = [];
$data[0] = '';
$data[1] = "<input type=submit name='add_custom' class='sub add right' value='".__('Add item')."'>";
$data[1] = "<input style='float:right;' type=submit name='add_custom' class='sub add' value='".__('Add item')."'>";
$table->data[] = $data;
$table->rowclass[] = '';
@ -570,7 +593,7 @@ if ($edit_container) {
$data = [];
$data[0] = '';
$data[1] = "<input type=submit name='add_dynamic' class='sub add right' value='".__('Add item')."'>";
$data[1] = "<input style='float:right;' type=submit name='add_dynamic' class='sub add' value='".__('Add item')."'>";
$table->data[] = $data;
$table->rowclass[] = '';
@ -582,11 +605,13 @@ if ($edit_container) {
echo '</tr>';
echo '</table>';
$total_item = db_get_all_rows_sql('SELECT count(*) FROM tcontainer_item WHERE id_container = '.$id_container);
$result_item = db_get_all_rows_sql('SELECT * FROM tcontainer_item WHERE id_container = '.$id_container.' LIMIT 10 OFFSET '.$offset);
if ((bool) $id_container !== false) {
$total_item = db_get_all_rows_sql('SELECT count(*) FROM tcontainer_item WHERE id_container = '.$id_container);
$result_item = db_get_all_rows_sql('SELECT * FROM tcontainer_item WHERE id_container = '.$id_container.' LIMIT 10 OFFSET '.$offset);
}
if (!$result_item) {
echo "<div class='nf'>".__('There are no defined item container').'</div>';
echo "<div class='nf'>".__('There are no items in this container.').'</div>';
} else {
ui_pagination($total_item[0]['count(*)'], false, $offset, 10);
$table = new stdClass();
@ -655,7 +680,7 @@ if ($edit_container) {
}
$data[7] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/create_container&edit_container=1&delete_item=1&id_item='.$item['id_ci'].'&id='.$id_container.'" onClick="if (!confirm(\''.__('Are you sure?').'\'))
return false;">'.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter']).'</a>';
return false;">'.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete')]).'</a>';
array_push($table->data, $data);
}
@ -753,4 +778,4 @@ echo html_print_input_hidden('id_agent', 0);
});
});
</script>
</script>

View File

@ -94,7 +94,7 @@ if ($edit_graph) {
} else {
$id_agent = 0;
$id_module = 0;
$id_group = 0;
$id_group = null;
$period = SECONDS_1DAY;
$factor = 1;
$stacked = 4;
@ -142,28 +142,36 @@ if (users_can_manage_group_all('RW') === false
$output .= '<td><b>'.__('Group').'</b></td><td>';
if (check_acl($config['id_user'], 0, 'RW')) {
$output .= html_print_select_groups(
$config['id_user'],
'RW',
$return_all_group,
'graph_id_group',
$id_group,
'',
'',
'',
true
$output .= html_print_input(
[
'type' => 'select_groups',
'id_user' => $config['id_user'],
'privilege' => 'RW',
'returnAllGroup' => $return_all_group,
'name' => 'graph_id_group',
'selected' => $id_group,
'script' => '',
'nothing' => '',
'nothing_value' => '',
'return' => true,
'required' => true,
]
);
} else if (check_acl($config['id_user'], 0, 'RM')) {
$output .= html_print_select_groups(
$config['id_user'],
'RM',
$return_all_group,
'graph_id_group',
$id_group,
'',
'',
'',
true
$output .= html_print_input(
[
'type' => 'select_groups',
'id_user' => $config['id_user'],
'privilege' => 'RM',
'returnAllGroup' => $return_all_group,
'name' => 'graph_id_group',
'selected' => $id_group,
'script' => '',
'nothing' => '',
'nothing_value' => '',
'return' => true,
'required' => true,
]
);
}

View File

@ -121,16 +121,20 @@ if (users_can_manage_group_all('RW') === true) {
}
$table->data['group'][1] = '<div class="w290px inline">';
$table->data['group'][1] .= html_print_select_groups(
$config['id_user'],
'AR',
$return_all_group,
'id_group',
$idGroupReport,
'',
'',
'',
true
$table->data['group'][1] .= html_print_input(
[
'type' => 'select_groups',
'id_user' => $config['id_user'],
'privilege' => 'AR',
'returnAllGroup' => $return_all_group,
'name' => 'id_group',
'selected' => $idGroupReport,
'script' => '',
'nothing' => '',
'nothing_value' => '',
'return' => true,
'required' => true,
]
);
$table->data['group'][1] .= '</div>';

View File

@ -1211,7 +1211,7 @@ switch ($action) {
switch ($activeTab) {
case 'main':
$reportName = '';
$idGroupReport = 0;
$idGroupReport = null;
// All groups.
$description = '';
$resultOperationDB = null;

View File

@ -141,16 +141,20 @@ if (users_can_manage_group_all('RW') === true) {
$return_all_group = true;
}
$table->data[1][1] = '<div class="w250px">'.html_print_select_groups(
$config['id_user'],
'RW',
$return_all_group,
'id_group',
$idGroup,
'',
'',
'',
true
$table->data[1][1] = '<div class="w250px">'.html_print_input(
[
'type' => 'select_groups',
'id_user' => $config['id_user'],
'privilege' => 'RW',
'returnAllGroup' => $return_all_group,
'name' => 'id_group',
'selected' => $idGroup,
'script' => '',
'nothing' => '',
'nothing_value' => '',
'return' => true,
'required' => true,
]
).'</div>';
$backgrounds_list = list_files(
$config['homedir'].'/images/console/background/',
@ -433,4 +437,4 @@ $(document).ready (function () {
}
});
</script>
</script>

View File

@ -576,6 +576,10 @@ function html_print_select_groups(
$required
);
if ($required !== false) {
$require_message = __('Please select an item from this list.');
}
if (empty($size) === true) {
$size = '100%';
}
@ -629,6 +633,25 @@ function html_print_select_groups(
}
}
});
<?php
if ($required !== false) {
?>
$(this).on('change', function(e) {
e.currentTarget.setCustomValidity('');
})
$(this).on('invalid', function(e) {
if ($(e.currentTarget).val() == null) {
e.currentTarget.setCustomValidity(
'<?php echo $require_message; ?>'
);
}
})
<?php
}
?>
}
);

View File

@ -33,7 +33,7 @@ if (empty($arrayDashboard) === true) {
$arrayDashboard['name'] = 'Default';
$arrayDashboard['id_user'] = '';
$private = 0;
$arrayDashboard['id_group'] = 0;
$arrayDashboard['id_group'] = null;
$arrayDashboard['active'] = 0;
$arrayDashboard['cells_slideshow'] = 0;
} else {
@ -112,6 +112,7 @@ $inputs = [
'returnAllGroup' => $return_all_group,
'selected' => $arrayDashboard['id_group'],
'return' => true,
'required' => true,
],
],
],

View File

@ -209,11 +209,16 @@ if (empty($dashboards) === true) {
}
if ($writeDashboards === 1) {
$text = __('Create a new dashboard');
if ($dashboard !== null) {
$text = __('Update Dashboard');
}
// Button for display modal options dashboard.
$output = '<a href="#" class="float-right" onclick=\'';
$output .= 'show_option_dialog('.json_encode(
[
'title' => __('Update Dashboard'),
'title' => $text,
'btn_text' => __('Ok'),
'btn_cancel' => __('Cancel'),
'url' => $ajaxController,