From d5197dcb40d516db0c4e90746337b015e912f3a6 Mon Sep 17 00:00:00 2001
From: zarzuelo <zarzuelo@gmail.com>
Date: Thu, 17 Mar 2011 18:12:03 +0000
Subject: [PATCH] 2011-03-17  Sergio Martin <sergio.martin@artica.es>

	* operation/integria_incidents
	operation/integria_incidents/incident.incident.php
	operation/integria_incidents/incident.php
	operation/integria_incidents/incident.files.php
	operation/integria_incidents/incident.tracking.php
	operation/integria_incidents/incident_detail.php
	operation/integria_incidents/incident.workunits.php
	operation/integria_incidents/incident.download_file.php
	operation/integria_incidents/incident.list.php
	operation/integria_incidents/incident_statistics.php: Added
	missed files from the last commit



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4106 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     |  14 +
 .../incident.download_file.php                |  36 ++
 .../integria_incidents/incident.files.php     |  72 +++
 .../integria_incidents/incident.incident.php  | 119 +++++
 .../integria_incidents/incident.list.php      | 133 ++++++
 .../operation/integria_incidents/incident.php | 270 +++++++++++
 .../integria_incidents/incident.tracking.php  |  45 ++
 .../integria_incidents/incident.workunits.php |  67 +++
 .../integria_incidents/incident_detail.php    | 428 ++++++++++++++++++
 .../incident_statistics.php                   |  67 +++
 10 files changed, 1251 insertions(+)
 create mode 100644 pandora_console/operation/integria_incidents/incident.download_file.php
 create mode 100644 pandora_console/operation/integria_incidents/incident.files.php
 create mode 100644 pandora_console/operation/integria_incidents/incident.incident.php
 create mode 100644 pandora_console/operation/integria_incidents/incident.list.php
 create mode 100755 pandora_console/operation/integria_incidents/incident.php
 create mode 100644 pandora_console/operation/integria_incidents/incident.tracking.php
 create mode 100644 pandora_console/operation/integria_incidents/incident.workunits.php
 create mode 100755 pandora_console/operation/integria_incidents/incident_detail.php
 create mode 100755 pandora_console/operation/integria_incidents/incident_statistics.php

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 903d67be5c..311a8d5fcd 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-17  Sergio Martin <sergio.martin@artica.es>
+
+	* operation/integria_incidents
+	operation/integria_incidents/incident.incident.php
+	operation/integria_incidents/incident.php
+	operation/integria_incidents/incident.files.php
+	operation/integria_incidents/incident.tracking.php
+	operation/integria_incidents/incident_detail.php
+	operation/integria_incidents/incident.workunits.php
+	operation/integria_incidents/incident.download_file.php
+	operation/integria_incidents/incident.list.php
+	operation/integria_incidents/incident_statistics.php: Added 
+	missed files from the last commit
+
 2011-03-17  Sergio Martin <sergio.martin@artica.es>
 
 	* pandoradb_data.sql
diff --git a/pandora_console/operation/integria_incidents/incident.download_file.php b/pandora_console/operation/integria_incidents/incident.download_file.php
new file mode 100644
index 0000000000..e280ef400f
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.download_file.php
@@ -0,0 +1,36 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+require_once ("../../include/functions_incidents.php");
+require_once ("../../include/config.php");
+
+$id_file = $_GET["id_file"];
+$filename = $_GET["filename"];
+$id_user = $_GET["id_user"];
+
+$integria_api = $config['integria_url']."/include/api.php?return_type=csv&user=".$config['id_user']."&pass=".$config['integria_api_password'];
+
+$url = $integria_api."&op=download_file&params=".$id_file;
+
+// Call the integria API
+$file = call_api($url);
+	
+header("Content-type: binary");
+header("Content-Disposition: attachment; filename=\"".$filename."\"");
+header("Pragma: no-cache");
+header("Expires: 0");
+
+echo base64_decode($file);
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.files.php b/pandora_console/operation/integria_incidents/incident.files.php
new file mode 100644
index 0000000000..08659bf498
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.files.php
@@ -0,0 +1,72 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $result;
+$table->width = "98%";
+$table->class = "databox";
+
+$table->data = array();
+
+$profiles = array();
+$table->data[0][0] = "<b>".__('File')."</b><br/>".print_input_file ('new_file', true, array('size' => "50%"));
+
+$table->data[1][0] = "<b>".__('Description')."</b><br/>".print_textarea('description', 3, 6, '' , '', true);
+
+$form = "<form method='post' action='' enctype='multipart/form-data'>";
+$form .= print_table($table, true);
+$form .= print_submit_button(__('Add'), 'submit_button', false, '', true);
+$form .= print_input_hidden('tab', 'files', true);
+$form .= print_input_hidden('attach_file', '1', true);
+$form .= print_input_hidden('id_incident', $id_incident, true);
+$form .= "</form>";
+
+toggle($form, __('Add a file'));
+
+unset($table);
+
+$table->width = "98%";
+$table->class = "databox";
+
+$table->head[0] = __('Filename');
+$table->head[1] = __('Timestamp');
+$table->head[2] = __('Description');
+$table->head[3] = __('Size');
+$table->head[4] = __('Delete');
+
+$table->data = array();
+
+if(isset($result['file'][0]) && is_array($result['file'][0])){
+	$files = $result['file'];
+}
+else {
+	$files = $result;
+}
+
+$row = 0;
+foreach($files as $value) {
+	$table->data[$row][0] = '<a href="operation/integria_incidents/incident.download_file.php?tab=files&id_incident='.$value['id_incidencia'].'&id_file='.$value['id_attachment'].'&filename='.$value['filename'].'&id_user='.$config['id_user'].'&rintegria_server='.$config['rintegria_server'].'">'.$value['filename'].'</a>';
+	$table->data[$row][1] = $value['id_usuario'];
+	if(is_array($value['description'])) {
+		$value['description'] = '';
+	}
+	$table->data[$row][2] = $value['description'];
+	$table->data[$row][3] = $value['size'];
+	$table->data[$row][4] = "<a href='index.php?sec=incidencias&sec2=operation/integria_incidents/incident&tab=files&id_incident=".$value['id_incidencia']."&delete_file=".$value['id_attachment']."'>".print_image("images/cross.png", true, array('title' => __('Delete file')))."</a>";
+	$row++;
+}
+
+print_table($table);
+
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.incident.php b/pandora_console/operation/integria_incidents/incident.incident.php
new file mode 100644
index 0000000000..f7087fba44
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.incident.php
@@ -0,0 +1,119 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $result;
+global $result_resolutions;
+global $result_status;
+global $result_sources;
+global $result_groups;
+global $result_users;
+
+$resolutions[0] = __('None');
+foreach($result_resolutions['resolution'] as $res) {
+	$resolutions[$res['id']] = $res['name'];
+}
+
+foreach($result_status['status'] as $st) {
+	$status[$st['id']] = $st['name'];
+}
+
+foreach($result_sources['source'] as $src) {
+	$sources[$src['id']] = $src['name'];
+}
+
+foreach($result_groups['group'] as $gr) {
+	$groups[$gr['id']] = $gr['name'];
+}
+
+foreach($result_users['id_user'] as $usr) {
+	$users[$usr] = $usr;
+}
+
+if(!isset($result['id_incidencia'])) {
+	$result['titulo'] = '';
+	$result['sla_disabled'] = 0;
+	$result['notify_email'] = 0;
+	$result['estado'] = 0;
+	$result['prioridad'] = 0;
+	$result['resolution'] = 0;
+	$result['id_parent'] = 0;
+	$result['origen'] = 0;
+	$result['id_incident_type'] = 0;
+	$result['id_task'] = 0;
+	$result['id_creator'] = $config['id_user'];
+	$result['id_grupo'] = 0;
+	$result['id_usuario'] = 0;
+	$result['id_task'] = 0;
+	$result['descripcion'] = '';
+	$result['epilog'] = '';
+}
+
+$table->width = "98%";
+$table->class = "databox";
+
+$table->data = array();
+$table->colspan[0][0] = 3;
+$table->colspan[3][0] = 3;
+$table->colspan[4][0] = 3;
+
+$table->data[0][0] = "<b>".__('Title')."</b><br/>".print_input_text("title", $result['titulo'], '', 50, 255, true);
+if(isset($result['id_incidencia'])) {
+	$table->data[1][2] = "<b>".__('Assigned user')."</b><br/>".print_select ($users, 'id_user', $result['id_usuario'], '', '', 0, true, false, false);
+}
+else {
+	$table->data[1][2] = "";
+}
+
+$table->data[1][0] = "<b>".__('Group')."</b><br/>".print_select ($groups, 'group', $result['id_grupo'], '', '', 0, true, false, false);
+$table->data[1][1] = "<b>".__('Priority')."</b><br/>".print_select (get_incidents_priorities (), 'priority', $result['prioridad'], '', '', 0, true, false, false);
+$table->data[1][2] = "<b>".__('Creator')."</b><br/>".$result['id_creator'];
+
+if(isset($result['id_incidencia'])) {
+	$table->data[2][0] = "<b>".__('Source')."</b><br/>".print_select ($sources, 'source', $result['origen'], '', '', 0, true, false, false);
+	$table->data[2][1] = "<b>".__('Resolution')."</b><br/>".print_select ($resolutions, 'resolution', $result['resolution'], '', '', 0, true, false, false);
+	$table->data[2][2] = "<b>".__('Status')."</b><br/>".print_select ($status, 'status', $result['estado'], '', '', 0, true, false, false);
+}
+
+if(is_array($result['descripcion'])) {
+	$result['descripcion'] = "";
+}
+
+$table->data[3][0] = "<b>".__('Description')."</b><br/>".print_textarea("description", 10, 6, $result['descripcion'] , '', true);
+
+if(isset($result['id_incidencia'])) {
+if(is_array($result['epilog'])) {
+	$result['epilog'] = implode(',', $result['epilog']);
+}
+$table->data[4][0] = "<b>".__('Resolution epilog')."</b><br/>".print_textarea("epilog", 10, 6, $result['epilog'] , '', true);
+}
+
+if(isset($result['id_incidencia'])) {
+	echo "<form method='post' action=''>";
+	print_table($table);
+	print_submit_button(__('Update'), 'submit_button');
+	print_input_hidden('tab', 'incident');
+	print_input_hidden('update_incident', '1');
+	print_input_hidden('id_incident', $result['id_incidencia']);
+	echo "</form>";
+}
+else {
+	echo "<form method='post' action=''>";
+	print_table($table);
+	print_submit_button(__('Create'), 'submit_button');
+	print_input_hidden('tab', 'incident');
+	print_input_hidden('create_incident', '1');
+	echo "</form>";
+}
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.list.php b/pandora_console/operation/integria_incidents/incident.list.php
new file mode 100644
index 0000000000..1890489738
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.list.php
@@ -0,0 +1,133 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $search_status;
+global $search_group;
+global $search_string;
+
+global $result;
+global $result_status;
+global $result_groups;
+global $result_resolutions;
+
+foreach($result_status['status'] as $st) {
+	$status[$st['id']] = $st['name'];
+}
+
+// Add special status cases
+$status[0] = __('Any');
+$status[-10] = __('Not closed');
+
+foreach($result_groups['group'] as $gr) {
+	$groups[$gr['id']] = $gr['name'];
+}
+
+$resolutions[0] = __('None');
+foreach($result_resolutions['resolution'] as $res) {
+	$resolutions[$res['id']] = $res['name'];
+}
+
+echo '<form method="post">';
+
+echo '<br><table width="98%" border=0>';
+echo '<tr>';
+echo '<td>';
+echo "<b>".__('Search string')."</b>";
+echo '</td>';
+echo '<td>';
+echo "<b>".__('Status')."</b>";
+echo '</td>';
+echo '<td>';
+echo "<b>".__('Group')."</b>";
+echo '</td>';
+echo '</tr><tr>';
+echo '<td>';
+print_input_text('search_string', $search_string, '');
+echo '</td>';
+echo '<td>';
+print_select ($status, 'search_status', $search_status, '', '', 0, false);
+echo '</td>';
+echo '<td>';
+print_select ($groups, 'search_group', $search_group, '', '', 0, false, false, false);
+echo '</td>';
+echo '<td>';
+print_submit_button (__('Search'));
+echo '</td>';
+echo '</tr></table>';
+
+echo '</form>';
+
+
+// Show headers
+$table->width = "98%";
+$table->class = "databox";
+$table->cellpadding = 4;
+$table->cellspacing = 4;
+$table->head = array ();
+$table->data = array ();
+$table->size = array ();
+$table->align = array ();
+
+$table->head[0] = __('ID');
+//$table->head[1] = __('SLA');
+$table->head[2] = __('Incident');
+$table->head[3] = __('Group');
+$table->head[4] = __('Status')."<br/><i>".__('Resolution')."</i>";
+$table->head[5] = __('Priority');
+$table->head[6] = __('Updated')."<br/><i>".__('Started')."</i>";
+$table->head[7] = __('Details');
+$table->head[8] = __('Creator');
+$table->head[9] = __('Owner');
+$table->head[10] = __('Action');
+
+$table->align[4] = "center";
+$table->align[5] = "center";
+
+if(isset($result['incident'][0]) && is_array($result['incident'][0])){
+	$incidents = $result['incident'];
+}
+else {
+	$incidents = $result;
+}
+
+$rowPair = true;
+$iterator = 0;
+foreach ($incidents as $row) {
+	if ($rowPair)
+		$table->rowclass[$iterator] = 'rowPair';
+	else
+		$table->rowclass[$iterator] = 'rowOdd';
+	$rowPair = !$rowPair;
+	$iterator++;
+	
+	$data = array();
+
+	$data[0] = '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$row["id_incidencia"].'">'.$row["id_incidencia"].'</a>';
+	//$data[1] = "";
+	$data[2] = '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$row["id_incidencia"].'">'.substr(safe_output($row["titulo"]),0,45).'</a>';
+	$data[3] = $groups[$row["id_grupo"]];
+	$data[4] = $status[$row["estado"]]."<br/><i>".$resolutions[$row["resolution"]]."</i>";
+	$data[5] = print_incidents_priority_img ($row["prioridad"], true);
+	$data[6] = print_timestamp ($row["actualizacion"], true)."<br/><i>".print_timestamp ($row["inicio"], true)."</i>";
+	$data[7] = $row["workunits_hours"]." ".__('Hours')."<br/>".$row["workunits_count"]." ".__('Workunits');
+	$data[8] = $row["id_creator"];
+	$data[9] = $row["id_usuario"];
+	$data[10] = "<a href='index.php?sec=incidencias&sec2=operation/integria_incidents/incident&delete_incident=".$row['id_incidencia']."'>".print_image("images/cross.png", true, array('title' => __('Delete incident')))."</a><a href='index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident=".$row["id_incidencia"]."'>".print_image("images/config.png", true, array('title' => __('View incident details')))."</a>";
+
+	array_push ($table->data, $data);
+}
+
+print_table ($table);
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.php b/pandora_console/operation/integria_incidents/incident.php
new file mode 100755
index 0000000000..c0209b613e
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.php
@@ -0,0 +1,270 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $config;
+require_once ("include/functions_incidents.php");
+
+check_login ();
+
+if (! check_acl ($config['id_user'], 0, "IR")) {
+	pandora_audit("ACL Violation","Trying to access incident viewer");
+	require ("general/noaccess.php");
+	exit;
+}
+
+$tab = get_parameter('tab', 'list');
+$id_incident = get_parameter('id_incident', 0);
+
+// We choose a strange token to use texts with commas, etc.
+$token = ';,;';
+
+// Header
+if($tab == 'list' || $tab == 'editor') {
+	$buttons = array(
+			'list' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' . 
+					print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
+			'editor' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=editor">' . 
+					print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'</a>'));
+}
+else {
+	$buttons = array(
+			'list' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' . 
+					print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
+			'incident' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$id_incident.'">' . 
+					print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .'</a>'),
+			'workunits' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=workunits&id_incident='.$id_incident.'">' . 
+					print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .'</a>'),
+			'files' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=files&id_incident='.$id_incident.'"">' . 
+					print_image ("images/file.png", true, array ("title" => __('Files'))) .'</a>'),
+			'tracking' => array(
+				'active' => false,
+				'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=tracking&id_incident='.$id_incident.'"">' . 
+					print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'</a>'));
+}
+	
+$buttons[$tab]['active'] = true;
+
+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."&params=".$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."&params=".$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 '<h3 class="error">'.__('File is too big').'</h3>';
+			break;
+		case 3:
+			echo '<h3 class="error">'.__('File was partially uploaded. Please try again').'</h3>';
+			break;
+		case 4:
+			echo '<h3 class="error">'.__('No file was uploaded').'</h3>';
+			break;
+		default:
+			echo '<h3 class="error">'.__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')</h3>';
+		}
+	}
+}
+
+$delete_file = get_parameter('delete_file', 0);
+
+if($delete_file != 0) {
+	$url = $integria_api."&op=delete_file&params=".$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&params=".$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."&params=".$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."&params=".$params;
+		$url_resolutions =  $integria_api."&op=get_incidents_resolutions";
+		$url_status =  $integria_api."&op=get_incidents_status";
+		$url_groups =  $integria_api."&op=get_groups&params=1";
+		break;
+	case 'incident':
+		$url = $integria_api."&op=get_incident_details&params=".$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&params=0";
+		$url_users =  $integria_api."&op=get_users";
+		break;
+	case 'workunits':
+		$url = $integria_api."&op=get_incident_workunits&params=".$id_incident;
+		break;
+	case 'files':
+		$url = $integria_api."&op=get_incident_files&params=".$id_incident;
+		break;
+	case 'tracking':
+		$url = $integria_api."&op=get_incident_tracking&params=".$id_incident;
+		break;
+}
+
+if(isset($url)) {
+	// Call the integria API
+	$xml = call_api($url);
+}
+else {
+	$xml = "<xml></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 '<div style="clear:both">&nbsp;</div>';
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.tracking.php b/pandora_console/operation/integria_incidents/incident.tracking.php
new file mode 100644
index 0000000000..8226d7d511
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.tracking.php
@@ -0,0 +1,45 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $result;
+
+$table->width = "98%";
+$table->class = "databox";
+
+$table->head[0] = __('Description');
+$table->head[1] = __('User');
+$table->head[2] = __('Date');
+
+$table->data = array();
+
+if(isset($result['tracking'][0]) && is_array($result['tracking'][0])){
+	$tracking = $result['tracking'];
+}
+else {
+	$tracking = $result;
+}
+
+$row = 0;
+foreach($tracking as $value) {
+	
+	$table->data[$row][0] = $value['description'];
+	$table->data[$row][1] = $value['id_user'];
+	$table->data[$row][2] = $value['timestamp'];
+	$row++;
+}
+
+print_table($table);
+
+?>
diff --git a/pandora_console/operation/integria_incidents/incident.workunits.php b/pandora_console/operation/integria_incidents/incident.workunits.php
new file mode 100644
index 0000000000..d8aefcd454
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident.workunits.php
@@ -0,0 +1,67 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+global $result;
+global $id_incident;
+
+$table->width = "98%";
+$table->class = "databox";
+
+$table->data = array();
+$table->colspan[1][0] = 3;
+
+$profiles = array();
+$default_time = "0.25";
+$table->data[0][0] = "<b>".__('Time used')."</b><br/>".print_input_text ('time_used', $default_time, '', 10, 255, true);
+$table->data[0][1] = "<b>".__('Have cost')."</b><br/>".print_checkbox ('have_cost', '', false, true);
+$table->data[0][2] = "<b>".__('Public')."</b><br/>".print_checkbox ('public', '', true, true);
+
+$table->data[1][0] = "<b>".__('Description')."</b><br/>".print_textarea('description', 3, 6, '' , '', true);
+
+$form = "<form method='post' action=''>";
+$form .= print_table($table, true);
+$form .= print_submit_button(__('Add'), 'submit_button', false, '', true);
+$form .= print_input_hidden('tab', 'workunits', true);
+$form .= print_input_hidden('create_workunit', '1', true);
+$form .= print_input_hidden('id_incident', $id_incident, true);
+$form .= print_input_hidden('profile', '0', true);
+$form .= "</form>";
+
+toggle($form, __('Add workunit'));
+
+if(isset($result['workunit'][0]) && is_array($result['workunit'][0])){
+	$workunits = $result['workunit'];
+}
+else {
+	$workunits = $result;
+}
+
+foreach($workunits as $value) {
+	$table->width = "98%";
+	$table->class = "databox";
+	$table->colspan[1][0] = 4;
+	$table->size[0] = "80%";
+	$table->size[1] = "20%";
+
+	$table->data = array();
+
+	$table->data[0][0] = $value['id_user']." ".__('said')." ".$value['timestamp'];
+	$table->data[0][1] = $value['duration']." ".__('Hours')." ".__('Public').": ".$value['public'];
+	
+	$table->data[1][0] = $value['description'];
+
+	print_table($table);
+}
+?>
diff --git a/pandora_console/operation/integria_incidents/incident_detail.php b/pandora_console/operation/integria_incidents/incident_detail.php
new file mode 100755
index 0000000000..373483c435
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident_detail.php
@@ -0,0 +1,428 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Load global vars
+
+global $config;
+require_once ("include/functions_incidents.php");
+require_once ("include/functions_events.php"); //To get events group information
+
+check_login ();
+
+if (! check_acl ($config["id_user"], 0, "IR")) {
+ 	// Doesn't have access to this page
+	pandora_audit("ACL Violation", "Trying to access incident details");
+	require ("general/noaccess.php");
+	exit;
+}
+
+$inicio = get_system_time (); //Just inits the variable
+$actualizacion = get_system_time ();
+
+// EDITION MODE
+if (isset ($_GET["id"])) {
+	$id_inc = (int) get_parameter_get ("id", 0);
+	
+	// Obtain group of this incident
+	$row = get_db_row ("tincidencia","id_incidencia",$id_inc);
+	
+	// Get values
+	$titulo = $row["titulo"];
+	$texto = $row["descripcion"];
+	$inicio = strtotime ($row["inicio"]); 
+	$actualizacion = strtotime ($row["actualizacion"]);
+	$estado = $row["estado"];
+	$prioridad = $row["prioridad"];
+	$origen = $row["origen"];
+	$usuario = $row["id_usuario"]; //owner
+	$id_grupo = $row["id_grupo"];
+	$id_creator = $row["id_creator"]; //creator
+	$id_lastupdate = $row["id_lastupdate"]; //last updater
+	
+	// Note add - everybody that can read incidents, can add notes
+	if (isset ($_GET["insertar_nota"])) {
+		$nota = get_parameter_post ("nota");
+
+		$values = array(
+			'id_usuario' => $config["id_user"],
+			'id_incident' => $id_inc,
+			'nota' => $nota);
+		$id_nota = process_sql_insert('tnota', $values);
+
+		if ($id_nota !== false) {
+			process_incidents_touch ($id_inc);
+		}
+		print_result_message ($id_nota,
+			__('Successfully added'),
+			__('Could not be added'));
+	}
+
+	// Delete note
+	if (isset ($_POST["delete_nota"])) {
+		$id_nota = get_parameter_post ("delete_nota", 0);
+		$note_user = get_incidents_notes_author ($id_nota);
+		if (((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($note_user == $config["id_user"])) OR ($id_owner == $config["id_user"])) { 
+		// Only admins (manage incident) or owners can modify
+		// incidents notes. note authors are 
+		// able to delete their own notes
+			$result = delete_incidents_note ($id_nota);
+
+			if (!empty ($result)) {
+				process_incidents_touch ($id_inc);
+			}
+			print_result_message ($id_nota,
+				__('Successfully deleted'),
+				__('Could not be deleted'));
+		}
+	}
+
+	// Delete file
+	if (((check_acl ($config["id_user"], $id_grupo, "IM")==1) OR ($id_owner == $config["id_user"])) AND isset ($_POST["delete_file"])) {
+		$file_id = (int) get_parameter_post ("delete_file", 0);
+		$filename = get_db_value ("filename", "tattachment", "id_attachment", $file_id);
+		
+		$result = process_sql_delete('tattachment', array('id_attachment' => $file_id));
+		
+		if (!empty ($result)) {
+			unlink ($config["attachment_store"]."/pand".$file_id."_".$filename);
+			process_incidents_touch ($id_inc);
+		}
+		
+		print_result_message ($result,
+			__('Successfully deleted'),
+			__('Could not be deleted'));
+	}
+
+	// Upload file
+	if ((check_acl ($config["id_user"], $id_grupo, "IW") == 1) AND isset ($_GET["upload_file"]) AND ($_FILES['userfile']['name'] != "")) {
+		$description = get_parameter_post ("file_description", __('No description available'));
+		
+		// Insert into database
+		$filename = safe_input ($_FILES['userfile']['name']);
+		$filesize = safe_input ($_FILES['userfile']['size']);
+
+		//The following is if you have clamavlib installed
+		//(php5-clamavlib) and enabled in php.ini
+		//http://www.howtoforge.com/scan_viruses_with_php_clamavlib
+		if (extension_loaded ('clamav')) {
+			cl_setlimits (5, 1000, 200, 0, 10485760);
+			$malware = cl_scanfile ($_FILES['file']['tmp_name']); 
+			if ($malware) {
+				$error = 'Malware detected: '.$malware.'<br>ClamAV version: '.clam_get_version();
+				die ($error); //On malware, we die because it's not good to handle it
+			}
+		}
+		
+		$values = array(
+			'id_incidencia' => $id_inc,
+			'id_usuario' => $config["id_user"],
+			'filename' => $filename,
+			'description' => $description,
+			'size' => $filesize);
+		$id_attachment = process_sql_insert('tattachment', $values);
+
+		// Copy file to directory and change name
+		if ($id_attachment !== false) {
+			$nombre_archivo = $config["attachment_store"]."/pand".$id_attachment."_".$filename;
+			$result = copy ($_FILES['userfile']['tmp_name'], $nombre_archivo);
+		}
+		else {
+			echo '<h3 class="error">'.__('File could not be saved due to database error').'</h3>';
+			$result = false;
+		}
+
+		if ($result !== false) {
+			unlink ($_FILES['userfile']['tmp_name']);
+			process_incidents_touch ($id_inc);
+		}
+		else {
+			process_sql_delete('tattachment', array('id_attachment' => $id_attachment));
+		}
+		
+		print_result_message ($result,
+			__('File uploaded'),
+			__('File could not be uploaded'));
+	}
+} // else Not given id
+// Create incident from event... read event data
+elseif (isset ($_GET["insert_form"])) {
+	$titulo = "";
+	$descripcion = "";
+	$origen = "";
+	$prioridad = 0;
+	$id_grupo = 0;
+	$estado = 0;
+	$texto = "";
+	$usuario = $config["id_user"];
+	$id_creator = $config["id_user"];
+	
+	if (isset ($_GET["from_event"])) {
+		$event = get_parameter_get ("from_event");
+		$titulo = get_event_description ($event);
+		$id_grupo = get_event_group ($event);
+		$origen = "Pandora FMS event";
+		unset ($event);
+	}
+	$prioridad = 0;
+	$id_grupo = 0;
+} else {
+	pandora_audit("HACK","Trying to get to incident details in an unusual way");
+	require ("general/noaccess.php");
+	exit;
+}
+
+
+
+// ********************************************************************************************************
+// ********************************************************************************************************
+// Show the form
+// ********************************************************************************************************
+
+//This is for the pretty slide down attachment form
+echo "<script type=\"text/javascript\">
+	$(document).ready(function() {
+		$('#file_control').hide();
+		$('#add_note').hide();
+		$('a.attachment').click(function() {
+			$('a.attachment').fadeOut('fast');
+			$('#file_control').slideDown('slow');
+			return false;
+		});
+		$('a.note_control').click(function() {
+			$('a.note_control').fadeOut('fast');
+			$('#add_note').slideDown('slow');
+			return false;
+		});
+	});</script>";
+
+if (isset ($id_inc)) { //If $id_inc is set (when $_GET["id"] is set, not $_GET["insert_form"]
+	print_page_header (__('Incident details'). ' #'.$id_inc, "images/book_edit.png", false, "", false, "");
+	echo '<form name="accion_form" method="POST" action="index.php?sec=incidencias&sec2=operation/incidents/incident&action=update">';
+	echo '<input type="hidden" name="id_inc" value="'.$id_inc.'">';
+} else {
+	print_page_header (__('Create incident'), "images/book_edit.png", false, "", false, "");
+	echo '<form name="accion_form" method="POST" action="index.php?sec=incidencias&sec2=operation/incidents/incident&action=insert">';
+}
+
+echo '<table cellpadding="4" cellspacing="4" class="databox" width="650px">';
+echo '<tr><td class="datos"><b>'.__('Incident').'</b></td><td colspan="3" class="datos">';
+
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_input_text ("titulo", $titulo,'', 70);
+} else {
+	print_input_text_extended ("titulo", $titulo, "", "", 70, "", false, "", "readonly"); 
+}
+
+echo '</td></tr>';
+
+echo '<tr><td class="datos2"><b>'.__('Opened at').'</b></td><td class="datos2"><i>'.date ($config['date_format'], $inicio).'</i></td>';
+echo '<td class="datos2"><b>'.__('Updated at').'</b><td class="datos2"><i>'.date ($config['date_format'], $actualizacion).'</i></td></tr>';
+
+echo '<tr><td class="datos"><b>'.__('Owner').'</b></td><td class="datos">';
+
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_select (get_users_info (), "usuario_form", $usuario, '', 'SYSTEM', '', false, false, true, "w135");
+} else {
+	print_select (get_users_info (), "usuario_form", $usuario, '', 'SYSTEM', '', false, false, true, "w135", true);
+}
+echo '</td><td class="datos"><b>'.__('Status').'</b></td><td class="datos">';
+
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135');
+}
+else {
+	print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135', true);
+}
+echo '</td></tr>';
+
+echo '<tr><td class="datos2"><b>'.__('Source').'</b></td><td class="datos2">';
+
+$fields = array ();
+$return = get_db_all_rows_sql ("SELECT origen FROM torigen ORDER BY origen");
+if ($return === false)
+	$return[0] = $estado; //Something must be displayed
+
+foreach ($return as $row) {
+	$fields[$row["origen"]] = $row["origen"];
+}
+
+// Only owner could change source or user with Incident management privileges
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135');
+}
+else {
+	print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135', true);
+}
+echo '</td><td class="datos2"><b>'.__('Group').'</b></td><td class="datos2">';
+
+// Group combo
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_select_groups($config["id_user"], "IR", true, "grupo_form", $id_grupo, '', '', '', false, false, false, 'w135');
+} else {
+	print_select_groups($config["id_user"], "IR", true, "grupo_form", $id_grupo, '', '', '', false, false, true, 'w135', true);
+}
+
+echo '</td></tr><tr><td class="datos"><b>'.__('Priority').'</b></td><td class="datos">';
+
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135');
+} else {
+	print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135', true);
+}
+
+echo '</td><td class="datos"><b>'.__('Creator').'</b></td><td class="datos">';
+if (empty ($id_creator)) {
+	echo 'SYSTEM';
+} else {
+	echo $id_creator.' (<i>'.get_user_fullname($id_creator).'</i>)';
+}
+
+echo '</td></tr><tr><td class="datos2" colspan="4">';
+
+if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+	print_textarea ("descripcion", 15, 80, $texto, 'style="height:200px;"');
+} else {
+	print_textarea ("descripcion", 15, 80, $texto, 'style="height:200px;" disabled');
+}
+
+echo '</td></tr></table><div style="width: 650px; text-align:right;">';
+
+// Only if user is the used who opened incident or (s)he is admin
+if (isset ($id_inc) AND ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"]))) {
+	print_submit_button (__('Update incident'), "accion", false, 'class="sub upd"');
+} elseif (check_acl ($config["id_user"], $id_grupo, "IW")) {
+	print_submit_button (__('Create'), "accion", false, 'class="sub wand"');
+} else {
+	print_submit_button (__('Submit'), "accion", true, 'class="sub upd"');
+}
+echo "</div></form>";
+
+//If we're actually working on an incident
+if (isset ($id_inc)) {
+	// ********************************************************************
+	// Notes 
+	// ********************************************************************
+	
+	echo '<div>';
+
+	echo '<a class="note_control" href="#">';
+	echo print_image ('images/add.png', true);
+	echo __('Add note');
+	echo '</a>';
+	echo '</div><div>';
+	echo '<form id="add_note" name="nota" method="POST" action="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&insertar_nota=1&id='.$id_inc.'"><h3>'.__('Add note').'</h3>';
+	echo '<table cellpadding="4" cellspacing="4" class="databox" width="600px">
+		<tr><td class="datos2"><textarea name="nota" rows="5" cols="70" style="height: 100px;"></textarea></td>
+		<td valign="bottom"><input name="addnote" type="submit" class="sub wand" value="'.__('Add').'"></td></tr>
+		</table></form></div><div>';
+
+	$result = get_incidents_notes ($id_inc);
+	
+	$table->cellpadding = 4;
+	$table->cellspacing = 4;
+	$table->class = "databox";
+	$table->width = 600;
+	$table->data = array ();
+	$table->head = array ();
+	
+	foreach ($result as $row) {
+		$data = array ();
+		$data[0] = print_image("images/page_white_text.png", true, array("border" => '0')); 
+		$data[1] = __('Author').': '.print_username ($row["id_usuario"], true).' ('.print_timestamp ($row["timestamp"], true).')';
+		array_push ($table->data, $data);
+		
+		$data = array ();
+		$data[0] = '';
+		if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($row["id_usuario"] == $config["id_user"])) {
+			$data[0] .= print_input_image ("delete_nota", "images/cross.png", $row["id_nota"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true);
+		}
+		$data[1] = $row["nota"];
+		array_push ($table->data, $data);
+	}
+	
+	if (!empty ($table->data)) {
+		echo "<h3>".__('Notes attached to incident').'</h3>';
+		echo '<form method="POST" action="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
+		print_table ($table);
+		echo '</form>';
+	}
+	unset ($table);
+	
+
+	// ************************************************************
+	// Files attached to this incident
+	// ************************************************************
+
+	$result = get_incidents_attach ($id_inc);
+
+	$table->cellpadding = 4;
+	$table->cellspacing = 4;
+	$table->class = "databox";
+	$table->width = 650;
+	$table->head = array ();
+	$table->data = array ();
+
+	$table->head[0] = __('Filename');
+	$table->head[1] = __('Description');
+	$table->head[2] = __('Size');
+	$table->head[3] = __('Delete');
+
+	$table->align[2] = "center";
+	$table->align[3] = "center";
+
+	foreach ($result as $row) {
+		$data[0] = print_image("images/disk.png", true, array("border" => '0', "align" => "top")) . '&nbsp;&nbsp;<a target="_new" href="attachment/pand'.$row["id_attachment"].'_'.$row["filename"].'"><b>'.$row["filename"].'</b></a>';
+		$data[1] = $row["description"];
+		$data[2] = format_for_graph ($row["size"])."B";
+		if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {
+			$data[3] = print_input_image ("delete_file", "images/cross.png", $row["id_attachment"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true);
+		} else {
+			$data[3] = '';
+		}
+		array_push ($table->data, $data);
+	}
+
+	if (!empty ($table->data)) {
+		echo "<h3>".__('Attached files')."</h3>";
+		echo '<form method="POST" action="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
+		print_table ($table);
+		echo '</form>';
+	}
+	unset ($table);
+
+	// ************************************************************
+	// Upload control
+	// ************************************************************
+
+
+	// Upload control
+	if ((check_acl($config["id_user"], $id_grupo, "IW")==1)) {
+
+		echo '<div>';
+		echo '<a class="attachment" href="#">';
+		echo print_image ('images/add.png', true);
+		echo __('Add attachment');
+		echo '</a>';
+		echo '</div>';
+
+		echo '<div><form method="post" id="file_control" action="index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id='.$id_inc.'&upload_file=1" enctype="multipart/form-data"><h3>'.__('Add attachment').'</h3>';
+		echo '<table cellpadding="4" cellspacing="3" class="databox" width="400">
+			<tr><td class="datos">'.__('Filename').'</td><td class="datos"><input type="file" name="userfile" value="userfile" class="sub" size="40" /></td></tr>
+			<tr><td class="datos2">'.__('Description').'</td><td class="datos2" colspan="3"><input type="text" name="file_description" size="47"></td></tr>
+			<tr><td colspan="2" style="text-align: right;">	<input type="submit" name="upload" value="'.__('Upload').'" class="sub wand"></td></tr>
+			</table></form></div>';
+	}
+}
+?>
diff --git a/pandora_console/operation/integria_incidents/incident_statistics.php b/pandora_console/operation/integria_incidents/incident_statistics.php
new file mode 100755
index 0000000000..36623ad6e1
--- /dev/null
+++ b/pandora_console/operation/integria_incidents/incident_statistics.php
@@ -0,0 +1,67 @@
+<?php
+
+// Pandora FMS - http://pandorafms.com
+// ==================================================
+// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
+// Please see http://pandorafms.org for full contribution list
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation for version 2.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+
+// Load global vars
+global $config;
+require_once ("include/fgraph.php");
+
+check_login ();
+
+if (! check_acl ($config['id_user'], 0, "IR") == 1) {
+	pandora_audit("ACL Violation", "Trying to access Incident section");
+	require ("general/noaccess.php");
+	exit;
+}
+print_page_header (__('Statistics'), "images/book_edit.png", false, "", false, "");
+
+echo '<table width="90%">
+	<tr><td valign="top"><h3>'.__('Incidents by status').'</h3>';
+if ($config['flash_charts']) {
+	echo graph_incidents_status ();
+}
+else {
+	echo '<img src="include/fgraph.php?tipo=estado_incidente" border="0"></td>';
+}
+echo '<td valign="top"><h3>'.__('Incidents by priority').'</h3>';
+if ($config['flash_charts']) {
+	echo grafico_incidente_prioridad ();
+}
+else {
+	echo '<img src="include/fgraph.php?tipo=prioridad_incidente" border="0"></td></tr>';
+}
+echo '<tr><td><h3>'.__('Incidents by group').'</h3>';
+if ($config['flash_charts']) {
+	echo grafico_incidente_prioridad ();
+}
+else {
+	echo '<img src="include/fgraph.php?tipo=group_incident" border="0"></td>';
+}
+echo '<td><h3>'.__('Incidents by user').'</h3>';
+if ($config['flash_charts']) {
+	echo grafico_incidente_prioridad ();
+}
+else {
+	echo '<img src="include/fgraph.php?tipo=user_incident" border="0"></td></tr>';
+}
+echo '<tr><td><h3>'.__('Incidents by source').'</h3>';
+if ($config['flash_charts']) {
+	echo grafico_incidente_prioridad ();
+}
+else {
+	echo '<img src="include/fgraph.php?tipo=source_incident" border="0"></td></tr>';
+}
+echo '</table>';
+?>