array(
'active' => false,
'text' => '' .
print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''),
'editor' => array(
'active' => false,
'text' => '' .
print_image ("images/add.png", true, array ("title" => __('New Incident'))) .''));
}
else {
$buttons = array(
'list' => array(
'active' => false,
'text' => '' .
print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''),
'incident' => array(
'active' => false,
'text' => '' .
print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .''),
'workunits' => array(
'active' => false,
'text' => '' .
print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .''),
'files' => array(
'active' => false,
'text' => '' .
print_image ("images/file.png", true, array ("title" => __('Files'))) .''),
'tracking' => array(
'active' => false,
'text' => '' .
print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .''));
}
$buttons[$tab]['active'] = true;
ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons);
$update_incident = get_parameter('update_incident', 0);
$integria_api = $config['integria_url']."/include/api.php?return_type=xml&user=".$config['id_user']."&pass=".$config['integria_api_password'];
if($update_incident == 1) {
$values[0] = $id_incident;
$values[1] = str_replace(" ", "%20", safe_output(get_parameter('title')));
$values[2] = str_replace(" ", "%20", safe_output(get_parameter('description')));
$values[3] = str_replace(" ", "%20", safe_output(get_parameter('epilog')));
$values[4] = get_parameter('group');
$values[5] = get_parameter('priority');
$values[6] = get_parameter('source');
$values[7] = get_parameter('resolution');
$values[8] = get_parameter('status');
$values[9] = get_parameter('creator', get_parameter('creator_fix'));
$params = implode($token, $values);
$url = $integria_api."&op=update_incident&token=".$token."¶ms=".$params;
// Call the integria API
$result = call_api($url);
}
$create_incident = get_parameter('create_incident', 0);
if($create_incident == 1) {
$values[0] = str_replace(" ", "%20", safe_output(get_parameter('title')));
$values[1] = get_parameter('group');
$values[2] = get_parameter('priority');
$values[3] = str_replace(" ", "%20", 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 = call_api($url);
}
$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] = str_replace(" ", "%20", 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 = call_api($url, array('params' => $params));
}
else {
switch ($_FILES['new_file']['error']) {
case 1:
echo '
'.__('File is too big').'
';
break;
case 3:
echo ''.__('File was partially uploaded. Please try again').'
';
break;
case 4:
echo ''.__('No file was uploaded').'
';
break;
default:
echo ''.__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')
';
}
}
}
$delete_file = get_parameter('delete_file', 0);
if($delete_file != 0) {
$url = $integria_api."&op=delete_file¶ms=".$delete_file;
// Call the integria API
$result = call_api($url);
}
$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 = call_api($url);
}
$create_workunit = get_parameter('create_workunit', 0);
if($create_workunit == 1) {
$values[0] = $id_incident;
$values[1] = str_replace(" ", "%20", 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 = call_api($url);
}
// 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':
$url = $integria_api."&op=get_incident_details¶ms=".$id_incident;
case 'editor':
$url_resolutions = $integria_api."&op=get_incidents_resolutions";
$url_status = $integria_api."&op=get_incidents_status";
$url_sources = $integria_api."&op=get_incidents_sources";
$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 = call_api($url);
}
else {
$xml = "";
}
// If is a valid XML, parse it
if(xml_parse(xml_parser_create(), $xml)) {
$result = xml_to_array($xml);
if($result == false) {
$result = array();
}
switch($tab) {
case 'list':
$result_resolutions = xml_to_array(call_api($url_resolutions));
$result_status = xml_to_array(call_api($url_status));
$result_groups = xml_to_array(call_api($url_groups));
require_once('incident.list.php');
break;
case 'editor':
case 'incident':
$result_resolutions = xml_to_array(call_api($url_resolutions));
$result_status = xml_to_array(call_api($url_status));
$result_sources = xml_to_array(call_api($url_sources));
$result_groups = xml_to_array(call_api($url_groups));
$result_users = xml_to_array(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;
}
}
echo '
';
?>