array( 'active' => false, 'text' => '' . html_print_image ("images/list.png", true, array ("title" => __('Incidents'))) .''), 'editor' => array( 'active' => false, 'text' => '' . html_print_image ("images/pen.png", true, array ("title" => __('New Incident'))) .'')); } else { $buttons = array( 'list' => array( 'active' => false, 'text' => '' . html_print_image ("images/list.png", true, array ("title" => __('Incidents'))) .''), 'incident' => array( 'active' => false, 'text' => '' . html_print_image ("images/zoom_mc.png", true, array ("title" => __('Incident details'))) .''), 'workunits' => array( 'active' => false, 'text' => '' . html_print_image ("images/star_white.png", true, array ("title" => __('Workunits'))) .''), 'files' => array( 'active' => false, 'text' => '' . html_print_image ("images/save_mc.png", true, array ("title" => __('Files'))) .''), 'tracking' => array( 'active' => false, 'text' => '' . html_print_image ("images/gm_log.png", true, array ("title" => __('Tracking'))) .'')); } $buttons[$tab]['active'] = true; ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons); if ($update_incident == 1) { $values[0] = $id_incident; $values[1] = urlencode(io_safe_output(get_parameter('title'))); $values[2] = urlencode(io_safe_output(get_parameter('description'))); $values[3] = urlencode(io_safe_output(get_parameter('epilog'))); $values[4] = get_parameter('group'); $values[5] = get_parameter('priority'); $values[6] = get_parameter('resolution'); $values[7] = get_parameter('status'); $values[8] = get_parameter('id_user_assigned'); $params = implode($token, $values); $url = $integria_api."&op=update_incident&token=".$token."¶ms=".$params; // Call the integria API $result = incidents_call_api($url); $result_array = incidents_xml_to_array($result); if ($result_array['data']) { ui_print_success_message (__("Incident updated")); } else { ui_print_error_message (__("There was a problem updating the incident, please check if any field was modified and the values are correct.")); } } $create_incident = get_parameter('create_incident', 0); if ($create_incident == 1) { $values[0] = urlencode(io_safe_output(get_parameter('title'))); $values[1] = get_parameter('group'); $values[2] = get_parameter('priority'); $values[3] = urlencode(io_safe_output(get_parameter('description'))); $values[4] = $config['integria_inventory']; $params = implode($token, $values); $url = $integria_api."&op=create_incident&token=".$token."¶ms=".$params; // Call the integria API $result = incidents_call_api($url); $result_array = incidents_xml_to_array($result); if ($result_array['data']) { ui_print_success_message (__("Incident created")); } else { ui_print_error_message (__("There was a problem creating incident")); } } $attach_file = get_parameter('attach_file', 0); if ($attach_file == 1) { if ($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) { $file_content = file_get_contents($_FILES["new_file"]["tmp_name"]); $values[0] = $id_incident; $values[1] = $_FILES['new_file']['name']; $values[2] = $_FILES['new_file']['size']; $values[3] = io_safe_output(get_parameter('description'), __('No description available')); $values[4] = base64_encode($file_content); $params = implode($token, $values); $url = $integria_api."&op=attach_file&token=".$token; // Call the integria API $result = incidents_call_api($url, array('params' => $params)); $result_array = incidents_xml_to_array($result); if ($result_array['data'] == 0) { ui_print_success_message (__("File uploaded")); } else { ui_print_error_message (__("There was a problem uploading file")); } } else { switch ($_FILES['new_file']['error']) { case 1: ui_print_error_message (__('File is too big')); break; case 3: ui_print_error_message (__('File was partially uploaded. Please try again')); break; case 4: ui_print_error_message (__('No file was uploaded')); break; default: ui_print_error_message (__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')'); break; } } } $delete_file = get_parameter('delete_file', 0); if ($delete_file != 0 && !$attach_file) { $url = $integria_api."&op=delete_file¶ms=".$delete_file; // Call the integria API $result = incidents_call_api($url); $result = incidents_call_api($url); $result_array = incidents_xml_to_array($result); if ($result_array['data'] == 0 || $result_array['data'] == -2) { ui_print_success_message (__("File deleted")); } else if ($result_array['data'] == -1) { ui_print_error_message (__("You user doesn't have enough rights to delete this file")); } } $delete_incident = get_parameter('delete_incident', 0); if ($delete_incident != 0) { $url = $integria_api."&op=delete_incident¶ms=".$delete_incident; // Call the integria API $result = incidents_call_api($url); $result_array = incidents_xml_to_array($result); if ($result_array['data']) { ui_print_success_message (__("Incident deleted")); } else { ui_print_error_message (__("There was a problem deteling incident")); } } $create_workunit = get_parameter('create_workunit', 0); if ($create_workunit == 1) { $values[0] = $id_incident; $values[1] = str_replace(" ", "%20", io_safe_output(get_parameter('description'))); $values[2] = get_parameter('time_used'); $values[3] = get_parameter('have_cost'); $values[4] = get_parameter('public'); $values[5] = get_parameter('profile'); $params = implode($token, $values); $url = $integria_api."&op=create_workunit&token=".$token."¶ms=".$params; // Call the integria API $result = incidents_call_api($url); $result_array = incidents_xml_to_array($result); if ($result_array['data']) { ui_print_success_message (__("Workunit added")); } else { ui_print_error_message (__("There was a problem adding workunit")); } } $params = array(); // Set the url with parameters to call the api switch ($tab) { case 'list': $search_string = get_parameter('search_string', ""); $params[0] = $search_string; $search_status = get_parameter('search_status', -10); $params[1] = $search_status; $search_group = get_parameter('search_group', 1); $params[2] = $search_group; $params = implode($token,$params); $url = $integria_api."&op=get_incidents&token=".$token."¶ms=".$params; $url_resolutions = $integria_api."&op=get_incidents_resolutions"; $url_status = $integria_api."&op=get_incidents_status"; $url_groups = $integria_api."&op=get_groups¶ms=1"; break; case 'incident': case 'editor': //Request incident information if any if ($id_incident) { $url = $integria_api."&op=get_incident_details¶ms=".$id_incident; } else { $url = $integria_api."&op=get_incident_details"; } $url_resolutions = $integria_api."&op=get_incidents_resolutions"; $url_status = $integria_api."&op=get_incidents_status"; $url_groups = $integria_api."&op=get_groups¶ms=0"; $url_users = $integria_api."&op=get_users"; break; case 'workunits': $url = $integria_api."&op=get_incident_workunits¶ms=".$id_incident; break; case 'files': $url = $integria_api."&op=get_incident_files¶ms=".$id_incident; break; case 'tracking': $url = $integria_api."&op=get_incident_tracking¶ms=".$id_incident; break; } if (isset($url)) { // Call the integria API $xml = incidents_call_api($url); } else { $xml = ""; } // If is a valid XML, parse it if (xml_parse(xml_parser_create(), $xml)) { // Check if xml is empty if($xml == "\n\n") { $result = false; } else { $result = incidents_xml_to_array($xml); } if($result == false) { $result = array(); } switch($tab) { case 'list': $result_resolutions = incidents_xml_to_array(incidents_call_api($url_resolutions)); $result_status = incidents_xml_to_array(incidents_call_api($url_status)); $result_groups = incidents_xml_to_array(incidents_call_api($url_groups)); require_once('incident.list.php'); break; case 'editor': case 'incident': $result_resolutions = incidents_xml_to_array(incidents_call_api($url_resolutions)); $result_status = incidents_xml_to_array(incidents_call_api($url_status)); $result_groups = incidents_xml_to_array(incidents_call_api($url_groups)); $result_users = incidents_xml_to_array(incidents_call_api($url_users)); require_once('incident.incident.php'); break; case 'workunits': require_once('incident.workunits.php'); break; case 'files': require_once('incident.files.php'); break; case 'tracking': require_once('incident.tracking.php'); break; } } else { ui_print_error_message(__("There is a error in the message from your Integria or there is not connection.")); } echo '
 
'; ?>