Inventory modules forms

This commit is contained in:
Jose Gonzalez 2023-03-07 14:59:59 +01:00
parent f01b18b965
commit 845a637082
2 changed files with 172 additions and 79 deletions

View File

@ -369,6 +369,17 @@ if ($result === false) {
$actionButtons = '';
if ($management_allowed === true) {
$actionButtons .= html_print_submit_button(
__('Create'),
'crt',
false,
[
'icon' => 'wand',
'form' => 'form_create',
],
true
);
$actionButtons .= html_print_submit_button(
__('Delete'),
'delete_btn',
@ -380,18 +391,6 @@ if ($result === false) {
],
true
);
$actionButtons .= html_print_submit_button(
__('Create'),
'crt',
false,
[
'icon' => 'wand',
'form' => 'form_create',
],
true
);
}
html_print_action_buttons(

View File

@ -26,22 +26,32 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'],
// Header
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$sec = 'advanced';
enterprise_include_once('meta/include/functions_components_meta.php');
components_meta_print_header();
} else {
$sec = 'gmodules';
ui_print_page_header(
__('Module management').' » '.__('Inventory modules'),
ui_print_standard_header(
__('Module management'),
'images/op_inventory.png',
false,
'',
true
true,
[],
[
[
'link' => '',
'label' => __('Configuration'),
],
[
'link' => '',
'label' => __('Inventory modules'),
],
]
);
}
// Header
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
ui_print_error_message(__('Not supported in Windows systems'));
@ -95,82 +105,166 @@ if ($id_os == null) {
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->class = 'databox filter-table-adv';
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->style[0] = 'width: 50%';
$table->style[1] = 'width: 50%';
$table->data = [];
$table->data[0][0] = '<strong>'.__('Name').'</strong>';
$table->data[0][1] = html_print_input_text('name', $name, '', 45, 100, true, $disabled);
$table->data[1][0] = '<strong>'.__('Description').'</strong>';
$table->data[1][1] = html_print_input_text('description', $description, '', 60, 500, true);
$table->data[2][0] = '<strong>'.__('OS').'</strong>';
$table->data[2][1] = html_print_select_from_sql(
'SELECT id_os, name FROM tconfig_os ORDER BY name',
'id_os',
$id_os,
'',
'',
'',
$return = true
$table->data[0][] = html_print_label_input_block(
__('Name'),
html_print_input_text(
'name',
$name,
'',
45,
100,
true,
$disabled
)
);
$table->data[3][0] = '<strong>'.__('Interpreter').'</strong>';
$table->data[3][1] = html_print_input_text('interpreter', $interpreter, '', 25, 100, true);
$table->data[3][1] .= ui_print_help_tip(__('Left blank for the LOCAL inventory modules'), true);
$table->data[0][] = html_print_label_input_block(
__('Description'),
html_print_input_text(
'description',
$description,
'',
60,
500,
true
)
);
$table->data['block_mode'][0] = '<strong>'.__('Block Mode').'</strong>';
$table->data['block_mode'][1] = html_print_checkbox('block_mode', 1, $block_mode, true);
$table->data[1][] = html_print_label_input_block(
__('OS'),
html_print_select_from_sql(
'SELECT id_os, name FROM tconfig_os ORDER BY name',
'id_os',
$id_os,
'',
'',
'',
$return = true
)
);
$table->data[4][0] = '<strong>'.__('Format').'</strong>';
$table->data[4][0] .= ui_print_help_tip(__('separate fields with ').SEPARATOR_COLUMN, true);
$table->data[4][1] = html_print_input_text('format', $data_format, '', 50, 100, true);
$table->data[1][] = html_print_label_input_block(
__('Interpreter'),
html_print_input_text(
'interpreter',
$interpreter,
'',
25,
100,
true
).ui_print_input_placeholder(
__('Left blank for the LOCAL inventory modules'),
true
)
);
$table->data[5][0] = '<strong>'.__('Script mode').'</strong>';
$table->data[5][0] .= ui_print_help_tip(__(''), true);
$table->data[5][1] = __('Use script');
$table->data[5][1] .= html_print_radio_button(
'script_mode',
1,
'',
$script_mode,
true
).'&nbsp;&nbsp;';
$table->data[5][1] .= '&nbsp&nbsp&nbsp&nbsp'.__('Use inline code');
$table->data[5][1] .= html_print_radio_button(
'script_mode',
2,
'',
$script_mode,
true
).'&nbsp;&nbsp;';
$table->data[2][] = html_print_label_input_block(
__('Format'),
html_print_input_text(
'format',
$data_format,
'',
50,
100,
true
).ui_print_input_placeholder(
__('separate fields with ').SEPARATOR_COLUMN,
true
)
);
$table->data[6][0] = '<strong>'.__('Script path').'</strong>';
$table->data[6][1] = html_print_input_text('script_path', $script_path, '', 50, 1000, true);
$table->data[2][] = html_print_label_input_block(
__('Block Mode'),
html_print_checkbox_switch(
'block_mode',
1,
$block_mode,
true
)
);
$table->data[7][0] = '<strong>'.__('Code').'</strong>';
$table->data[7][0] .= ui_print_help_tip(__("Here is placed the script for the REMOTE inventory modules Local inventory modules don't use this field").SEPARATOR_COLUMN, true);
$radioButtons = [];
$radioButtons[] = html_print_radio_button('script_mode', 1, __('Script mode'), $script_mode, true);
$radioButtons[] = html_print_radio_button('script_mode', 2, __('Use inline code'), $script_mode, true);
$table->data[7][1] = html_print_textarea('code', 25, 80, base64_decode($code), '', true);
$table->data[3][] = html_print_label_input_block(
__('Script mode'),
html_print_div(
[
'class' => 'switch_radio_button',
'content' => implode('', $radioButtons),
],
true
)
);
echo '<form name="inventorymodule" id="inventorymodule_form" method="post"
$table->colspan[4][0] = 2;
$table->data[4][0] = html_print_label_input_block(
__('Script path'),
html_print_input_text(
'script_path',
$script_path,
'',
50,
1000,
true
),
['div_class' => 'script_path_inventory_modules']
);
$table->data[4][0] .= html_print_label_input_block(
__('Code'),
html_print_textarea(
'code',
25,
80,
base64_decode($code),
'',
true
).ui_print_input_placeholder(
__("Here is placed the script for the REMOTE inventory modules Local inventory modules don't use this field").SEPARATOR_COLUMN,
true
),
['div_class' => 'code_inventory_modules']
);
echo '<form name="inventorymodule" id="inventorymodule_form" class="max_floating_element_size" method="post"
action="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules">';
html_print_table($table);
if ($id_module_inventory) {
html_print_input_hidden('update_module_inventory', 1);
html_print_input_hidden('id_module_inventory', $id_module_inventory);
$buttonCaption = __('Update');
$buttonIcon = 'update';
} else {
html_print_input_hidden('create_module_inventory', 1);
$buttonCaption = __('Create');
$buttonIcon = 'wand';
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_module_inventory) {
html_print_submit_button(__('Update'), 'submit', false, 'class="sub next"');
} else {
html_print_submit_button(__('Create'), 'submit', false, 'class="sub upd"');
}
$actionButtons = '';
$actionButtons = html_print_submit_button(
$buttonCaption,
'submit',
false,
['icon' => $buttonIcon],
true
);
$actionButtons .= html_print_go_back_button(
'index.php?sec=gmodules&sec2=godmode/modules/manage_inventory_modules',
['button_class' => ''],
true
);
echo '</div>';
html_print_action_buttons($actionButtons);
echo '</form>';
?>
@ -180,21 +274,21 @@ echo '</form>';
var mode = <?php echo $script_mode; ?>;
if (mode == 1) {
$('#table1-6').show();
$('#table1-7').hide();
$('.script_path_inventory_modules').show();
$('.code_inventory_modules').hide();
} else {
$('#table1-7').show();
$('#table1-6').hide();
$('.code_inventory_modules').show();
$('.script_path_inventory_modules').hide();
}
$('input[type=radio][name=script_mode]').change(function() {
if (this.value == 1) {
$('#table1-6').show();
$('#table1-7').hide();
$('.script_path_inventory_modules').show();
$('.code_inventory_modules').hide();
}
else if (this.value == 2) {
$('#table1-7').show();
$('#table1-6').hide();
$('.code_inventory_modules').show();
$('.script_path_inventory_modules').hide();
}
});
});