ping(); $group_values = $ITSM->getGroups(); $priority_values = $ITSM->getPriorities(); $status_values = $ITSM->getStatus(); $object_types_values = $ITSM->getObjectypes(); if ((bool) get_parameter('update_config', 0) === true) { $set_config_inventories = $ITSM->createNode( [ 'serverAuth' => $config['server_unique_identifier'], 'apiPass' => $config['api_password'], 'agentsForExecution' => $config['ITSM_agents_sync'], 'path' => $config['ITSM_public_url'], 'label' => array_keys(servers_get_names())[0], 'nodeId' => $config['metaconsole_node_id'], ] ); } try { $node = $ITSM->getNode($config['server_unique_identifier']); } catch (\Throwable $th) { $node = []; } } catch (\Throwable $th) { $error = $th->getMessage(); $has_connection = false; } if ($has_connection === false && $config['ITSM_enabled']) { ui_print_error_message(__('ITSM API is not reachable, %s', $error)); } $table_enable = new StdClass(); $table_enable->data = []; $table_enable->width = '100%'; $table_enable->id = 'itsm-enable-setup'; $table_enable->class = 'databox filters'; $table_enable->size['name'] = '30%'; $table_enable->style['name'] = 'font-weight: bold'; // Enable Pandora ITSM. $row = []; $row['name'] = __('Enable Pandora ITSM'); $row['control'] = html_print_checkbox_switch('ITSM_enabled', 1, $config['ITSM_enabled'], true); $table_enable->data['ITSM_enabled'] = $row; // Remote config table. $table_remote = new StdClass(); $table_remote->data = []; $table_remote->width = '100%'; $table_remote->styleTable = 'margin-bottom: 10px;'; $table_remote->id = 'ITSM-remote-setup'; $table_remote->class = 'databox filters filter-table-adv'; $table_remote->size['hostname'] = '50%'; $table_remote->size['api_pass'] = '50%'; // Enable ITSM user configuration. $row = []; $row['user_level'] = html_print_label_input_block( __('Pandora ITSM configuration at user level'), html_print_checkbox_switch( 'ITSM_user_level_conf', 1, $config['ITSM_user_level_conf'], true ) ); $table_remote->data['ITSM_user_level_conf'] = $row; // ITSM hostname. $row = []; $row['hostname'] = html_print_label_input_block( __('URL to Pandora ITSM setup').ui_print_help_tip( __('Full URL to your Pandora ITSM setup (e.g., http://192.168.1.20/integria/api/v1).'), true ), html_print_input_text( 'ITSM_hostname', $config['ITSM_hostname'], '', 30, 100, true ), ['div_class' => 'ITSM-remote-setup-ITSM_hostname'] ); // ITSM token. $row['password'] = html_print_label_input_block( __('Token'), html_print_input_password( 'ITSM_token', io_output_password($config['ITSM_token']), '', 30, 100, true ), ['div_class' => 'ITSM-remote-setup-ITSM_token'] ); $table_remote->data['ITSM_token'] = $row; // Test. $row = []; $button_test = html_print_button( __('Test'), 'ITSM', false, '', [ 'icon' => 'cog', 'mode' => 'secondary mini', ], true ); $button_test .= ' '; $button_test .= html_print_image( 'images/spinner.gif', true ); $button_test .= ''; $button_test .= ' '; $button_test .= html_print_image( 'images/status_sets/default/severity_normal.png', true ); $button_test .= ' '.__('Connection its OK').''; $button_test .= ' '; $button_test .= html_print_image( 'images/status_sets/default/severity_critical.png', true ); $button_test .= ' '.__('Connection failed').''; $button_test .= ' '; $row['control'] = html_print_label_input_block( __('Test connection pandora to ITSM'), $button_test, ['div_class' => 'ITSM-remote-setup-ITSM_token'] ); $table_remote->data['ITSM_test'] = $row; $row = []; $itsm_public_url = $config['ITSM_public_url']; if (empty($itsm_public_url) === true) { $itsm_public_url = $config['homeurl']; if (isset($config['public_url']) === true && empty($config['public_url']) === false) { $itsm_public_url = $config['public_url']; } } $row['publicUrl'] = html_print_label_input_block( __('URL conect to API %s', get_product_name()).ui_print_help_tip( __('Full URL to your Pandora (e.g., http://192.168.1.20).'), true ), html_print_input_text( 'ITSM_public_url', $itsm_public_url, '', 30, 100, true ) ); $row['agentsSync'] = html_print_label_input_block( __('Number Agents to synchronize').ui_print_help_tip( __('Number of agents that will synchronize at the same time, minimum 10 max 1000'), true ), html_print_input_number( [ 'name' => 'ITSM_agents_sync', 'min' => 10, 'max' => 1000, 'value' => ($config['ITSM_agents_sync'] ?? 20), ] ) ); $table_remote->data['ITSM_sync_inventory'] = $row; // Test. $row = []; $button_test_pandora = html_print_button( __('Test'), 'ITSM-pandora', false, '', [ 'icon' => 'cog', 'mode' => 'secondary mini', ], true ); $button_test_pandora .= ' '; $button_test_pandora .= html_print_image( 'images/spinner.gif', true ); $button_test_pandora .= ''; $button_test_pandora .= ' '; $button_test_pandora .= html_print_image( 'images/status_sets/default/severity_normal.png', true ); $button_test_pandora .= ' '.__('Connection its OK').''; $button_test_pandora .= ' '; $button_test_pandora .= html_print_image( 'images/status_sets/default/severity_critical.png', true ); $button_test_pandora .= ' '.__('Connection failed').''; $button_test_pandora .= ' '; $row['control-test'] = html_print_label_input_block( __('Test conection ITSM to pandora'), $button_test_pandora ); if (empty($node) === false) { $progressbar = ''; $progress = 0; if (empty($node['total']) === false) { if (empty($node['accumulate']) === true) { $node['accumulate'] = 0; } $progress = round(($node['accumulate'] * 100 / $node['total'])); } if (empty($node['error']) === false) { $progressbar = $node['error']; } else if (empty($node['total']) === false) { $progressbar = '