Group selection review

This commit is contained in:
fbsanchez 2020-09-29 14:22:58 +02:00
parent 5f4893ef1a
commit 5d63bc547e
9 changed files with 173 additions and 133 deletions

View File

@ -53,7 +53,28 @@ foreach ($groups as $id => $name) {
$row = [];
$row[0] = __('Groups');
$row[1] = html_print_select($groups, 'groups[]', $groups_selected, '', '', '', true, true, '', '', '');
$row[1] = '<div class="w290px">'.html_print_select_groups(
// Id_user.
false,
// Privilege.
'AR',
// ReturnAllGroup.
true,
// Name.
'groups[]',
// Selected.
$groups_selected,
// Script.
'',
// Nothing.
'',
// Nothing_value.
0,
// Return.
true,
// Multiple.
true
).'</div>';
$table->data[] = $row;
$table->colspan[][1] = 3;

View File

@ -645,7 +645,7 @@ $table->data[0][1] = html_print_input_text(
$disabled_in_execution
);
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(
$table->data[1][1] = '<div class="w250px">'.html_print_select_groups(
false,
$access,
true,
@ -659,7 +659,7 @@ $table->data[1][1] = html_print_select_groups(
true,
'',
$disabled_in_execution
);
).'</div>';
$table->data[2][0] = __('Description');
$table->data[2][1] = html_print_textarea(
'description',

View File

@ -222,12 +222,14 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
}
echo "<td style='width: 12%;'><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 '</div>';
echo '</td></tr>';
echo '<tr>';
@ -500,7 +502,7 @@ if ($edit_container) {
$data = [];
$data[0] = __('Group');
$data[1] = html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'container_id_group', $id_group, '', '', '', true);
$data[1] = '<div class="w250px">'.html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'container_id_group', $id_group, '', '', '', true).'</div>';
$table->data[] = $data;
$table->rowclass[] = '';

View File

@ -1125,11 +1125,11 @@ $class = 'databox filters';
</td>
<td style="font-weight:bold;">
<?php
<?php
html_print_checkbox_switch(
'current_month',
1,
$current_month
'current_month',
1,
$current_month
);
?>
</td>
@ -1145,16 +1145,16 @@ $class = 'databox filters';
<tr>
<td>
<p style="margin-right:30px;">
<?php
echo __('Monday')."<br>";
<?php
echo __('Monday').'<br>';
html_print_checkbox_switch('monday', 1, $monday);
?>
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Tuesday')."<br>";
echo __('Tuesday').'<br>';
html_print_checkbox_switch('tuesday', 1, $tuesday);
?>
</p>
@ -1162,7 +1162,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Wednesday')."<br>";
echo __('Wednesday').'<br>';
html_print_checkbox_switch('wednesday', 1, $wednesday);
?>
</p>
@ -1170,7 +1170,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Thursday')."<br>";
echo __('Thursday').'<br>';
html_print_checkbox_switch('thursday', 1, $thursday);
?>
</p>
@ -1178,7 +1178,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Friday')."<br>";
echo __('Friday').'<br>';
html_print_checkbox_switch('friday', 1, $friday);
?>
</p>
@ -1186,7 +1186,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Saturday')."<br>";
echo __('Saturday').'<br>';
html_print_checkbox_switch('saturday', 1, $saturday);
?>
</p>
@ -1194,7 +1194,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Sunday')."<br>";
echo __('Sunday').'<br>';
html_print_checkbox_switch('sunday', 1, $sunday);
?>
</p>
@ -1260,6 +1260,7 @@ $class = 'databox filters';
<td style="font-weight:bold;"><?php echo __('Group'); ?></td>
<td style="">
<?php
echo '<div class="w250px inline padding-right-2-imp">';
if (check_acl($config['id_user'], 0, 'RW')) {
html_print_select_groups(
$config['id_user'],
@ -1280,6 +1281,8 @@ $class = 'databox filters';
);
}
echo '</div>';
echo '&nbsp;&nbsp;&nbsp;'.__('Recursion').'&nbsp;&nbsp;&nbsp;'.html_print_checkbox_switch(
'recursion',
1,
@ -2117,13 +2120,14 @@ $class = 'databox filters';
);
?>
</td>
<td><?php
html_print_checkbox_switch(
'fullscale',
1,
$fullscale
);
?>
<td>
<?php
html_print_checkbox_switch(
'fullscale',
1,
$fullscale
);
?>
</td>
</tr>
@ -2194,7 +2198,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Total time')."<br>";
echo __('Total time').'<br>';
html_print_checkbox_switch('total_time', 1, $total_time);
?>
</p>
@ -2202,7 +2206,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Time failed')."<br>";
echo __('Time failed').'<br>';
html_print_checkbox_switch('time_failed', 1, $time_failed);
?>
</p>
@ -2210,7 +2214,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Time in OK status')."<br>";
echo __('Time in OK status').'<br>';
html_print_checkbox_switch('time_in_ok_status', 1, $time_in_ok_status);
?>
</p>
@ -2218,7 +2222,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Time in unknown status')."<br>";
echo __('Time in unknown status').'<br>';
html_print_checkbox_switch(
'time_in_unknown_status',
1,
@ -2230,7 +2234,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Time of not initialized module')."<br>";
echo __('Time of not initialized module').'<br>';
html_print_checkbox_switch(
'time_of_not_initialized_module',
1,
@ -2242,7 +2246,7 @@ $class = 'databox filters';
<td>
<p style="margin-right:30px;">
<?php
echo __('Time of downtime')."<br>";
echo __('Time of downtime').'<br>';
html_print_checkbox_switch('time_of_downtime', 1, $time_of_downtime);
?>
</p>

View File

@ -92,122 +92,113 @@ $table->data['group'][0] = __('Group');
$write_groups = users_get_groups_for_select(false, 'AR', true, true, false, 'id_grupo');
html_print_select_groups(
$config['id_user'],
'AR',
true,
'id_group',
$idGroup,
// If the report group is not among the RW groups (special permission) we add it
if (!isset($write_groups[$idGroupReport]) && $idGroupReport) {
$write_groups[$idGroupReport] = groups_get_name($idGroupReport);
}
$table->data['group'][1] = '<div class="w290px inline">';
$table->data['group'][1] .= html_print_select_groups(
$config['id_user'],
'AR',
true,
'id_group',
$idGroup,
'',
'',
'',
true
);
$table->data['group'][1] .= '</div>';
if ($report_id_user == $config['id_user']
|| is_user_admin($config['id_user'])
) {
// S/he is the creator of report (or admin) and s/he can change the access.
$type_access = [
'group_view' => __('Only the group can view the report'),
'group_edit' => __('The next group can edit the report'),
'user_edit' => __('Only the user and admin user can edit the report'),
];
$table->data['access'][0] = __('Write Access').ui_print_help_tip(__('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true);
$table->data['access'][1] = html_print_select(
$type_access,
'type_access',
$type_access_selected,
'change_type_access(this)',
'',
0,
true
);
$style = 'display: none;';
if ($type_access_selected == 'group_edit') {
$style = '';
}
$table->data['access'][1] .= '<span style="'.$style.'" class="access_subform" id="group_edit">';
$table->data['access'][1] .= '<div class="w290px inline">';
$table->data['access'][1] .= html_print_select_groups(
false,
'RW',
false,
'id_group_edit',
$id_group_edit,
false,
'',
'',
true
);
$table->data['access'][1] .= '</div>';
$table->data['access'][1] .= '</span>';
}
// If the report group is not among the RW groups (special permission) we add it
if (!isset($write_groups[$idGroupReport]) && $idGroupReport) {
$write_groups[$idGroupReport] = groups_get_name($idGroupReport);
if ($enterpriseEnable) {
$non_interactive_check = false;
if (isset($non_interactive)) {
$non_interactive_check = $non_interactive;
}
$table->data['group'][1] = html_print_select(
$write_groups,
'id_group',
$idGroupReport,
false,
$table->data['interactive_report'][0] = __('Non interactive report');
$table->data['interactive_report'][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button(
'non_interactive',
1,
'',
$non_interactive_check,
true
).'&nbsp;&nbsp;';
$table->data['interactive_report'][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button(
'non_interactive',
0,
'',
true,
false,
false
$non_interactive_check,
true
);
}
if ($report_id_user == $config['id_user']
|| is_user_admin($config['id_user'])
) {
// S/he is the creator of report (or admin) and s/he can change the access.
$type_access = [
'group_view' => __('Only the group can view the report'),
'group_edit' => __('The next group can edit the report'),
'user_edit' => __('Only the user and admin user can edit the report'),
];
$table->data['access'][0] = __('Write Access').ui_print_help_tip(__('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true);
$table->data['access'][1] = html_print_select(
$type_access,
'type_access',
$type_access_selected,
'change_type_access(this)',
'',
0,
true
);
$table->data['description'][0] = __('Description');
$table->data['description'][1] = html_print_textarea('description', 5, 15, $description, '', true);
$style = 'display: none;';
if ($type_access_selected == 'group_edit') {
$style = '';
}
echo '<form class="" method="post">';
html_print_table($table);
$table->data['access'][1] .= '<span style="'.$style.'" class="access_subform" id="group_edit">
'.html_print_select_groups(
false,
'RW',
false,
'id_group_edit',
$id_group_edit,
false,
'',
'',
true
).'
</span>';
}
if ($enterpriseEnable) {
$non_interactive_check = false;
if (isset($non_interactive)) {
$non_interactive_check = $non_interactive;
}
$table->data['interactive_report'][0] = __('Non interactive report');
$table->data['interactive_report'][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button(
'non_interactive',
1,
'',
$non_interactive_check,
true
).'&nbsp;&nbsp;';
$table->data['interactive_report'][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button(
'non_interactive',
0,
'',
$non_interactive_check,
true
);
}
$table->data['description'][0] = __('Description');
$table->data['description'][1] = html_print_textarea('description', 5, 15, $description, '', true);
echo '<form class="" method="post">';
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo $actionButtonHtml;
html_print_input_hidden('action', $hiddenFieldAction);
html_print_input_hidden('id_report', $idReport);
echo '</div></form>';
?>
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo $actionButtonHtml;
html_print_input_hidden('action', $hiddenFieldAction);
html_print_input_hidden('id_report', $idReport);
echo '</div></form>';
?>
<script type="text/javascript">
function change_type_access(select_item) {
$(".access_subform").hide();
switch ($(select_item).val()) {
case 'group_view':
break;
case 'group_edit':
$("#group_edit").show();
break;
case 'user_edit':
break;
if ($(select_item).val() == "group_edit") {
$("#group_edit").show()
} else {
$("#group_edit").hide()
}
}
</script>

View File

@ -493,7 +493,7 @@ function html_print_select_groups(
if (is_array($selected) === false) {
if (empty($selected) === false) {
$fields = [ $selected => groups_get_name($selected) ];
} else if ($returnAllGroup === true) {
} else if ($returnAllGroup === true && $multiple === false) {
$fields = [ $selected => groups_get_name(null, true) ];
}
} else {
@ -551,6 +551,8 @@ function html_print_select_groups(
$('select[name="<?php echo $name; ?>"]').each(
function() {
$(this).select2({
multiple: <?php echo ($multiple) ? 'true' : 'false'; ?>,
placeholder: "<?php echo __('Please select...'); ?>",
debug: 0,
width: '<?php echo $size; ?>',
templateResult: function(node) {
@ -582,6 +584,14 @@ function html_print_select_groups(
});
}
);
<?php
if (empty($fields) === true) {
?>
$('select[name="<?php echo $name; ?>"]').val(null).trigger("change");
<?php
}
?>
});
</script>

View File

@ -461,6 +461,10 @@ select:-internal-list-box {
width: 250px;
max-width: 250px;
}
.w290px {
width: 290px;
max-width: 290px;
}
.mw120px {
min-width: 120px;
}

View File

@ -37,9 +37,11 @@ if (! check_acl($config['id_user'], 0, 'ER') && ! check_acl($config['id_user'],
}
$agents = agents_get_group_agents(0, false, 'none', false, true);
ob_start('ui_process_page_head');
ob_start();
echo '<html>';
echo '<head>';
echo '<title>'.__('Sound Events').'</title>';
?>
<style type='text/css'>
@ -100,8 +102,6 @@ $table->data[0][3] .= html_print_image('images/tick_sound_events.png', true, ['i
html_print_table($table);
?>
<script src="../../include/javascript/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var group = 0;
var alert_fired = true;
@ -265,5 +265,11 @@ $(document).ready (function () {
<?php
echo '</body>';
while (@ob_end_flush()) {
// Dumping...
continue;
}
echo '</html>';

View File

@ -338,12 +338,14 @@ if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $confi
echo '</td><td class="datos2"><b>'.__('Group').'</b></td><td class="datos2">';
// Group combo
echo '<div class="w250px">';
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {
html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, false, 'w135');
} else {
html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, true, 'w135', true);
}
echo '</div>';
echo '</td></tr><tr><td class="datos"><b>'.__('Priority').'</b></td><td class="datos">';
if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) {