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

View File

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