function create_workunit($incident_id, $wu_text, $user, $timeused = 0, $have_cost = 0, $profile = "", $public = 1, $send_email = 1, $work_home = 0, $workflow = false)
{
    $fecha = print_mysql_timestamp();
    $sql = sprintf('UPDATE tincidencia
		SET affected_sla_id = 0, actualizacion = "%s"  
		WHERE id_incidencia = %d', $fecha, $incident_id);
    process_sql($sql);
    if (!$workflow) {
        incident_tracking($incident_id, INCIDENT_WORKUNIT_ADDED);
    }
    // Add work unit if enabled
    $sql = sprintf('INSERT INTO tworkunit (timestamp, duration, id_user, description, public, work_home)
			VALUES ("%s", %.2f, "%s", "%s", %d, %d)', $fecha, $timeused, $user, $wu_text, $public, $work_home);
    $id_workunit = process_sql($sql, "insert_id");
    $sql = sprintf('INSERT INTO tworkunit_incident (id_incident, id_workunit)
			VALUES (%d, %d)', $incident_id, $id_workunit);
    $res = process_sql($sql);
    if ($res !== false) {
        // Email notify to all people involved in this incident
        $email_notify = get_db_value("notify_email", "tincidencia", "id_incidencia", $incident_id);
        if ($email_notify == 1 and $send_email == 1) {
            mail_incident($incident_id, $user, $wu_text, $timeused, 10, $public);
        }
    } else {
        //Delete workunit
        $sql = sprintf('DELETE FROM tworkunit WHERE id = %d', $id_workunit);
        return false;
    }
    return $id_workunit;
}
function create_workunit($incident_id, $wu_text, $user, $timeused = 0, $have_cost = 0, $profile = "", $public = 1, $send_email = 1, $work_home = 0, $workflow = false)
{
    global $config;
    $fecha = print_mysql_timestamp();
    $sql = sprintf('UPDATE tincidencia
		SET affected_sla_id = 0, actualizacion = "%s"  
		WHERE id_incidencia = %d', $fecha, $incident_id);
    process_sql($sql);
    $task_id = get_db_value('id_task', 'tincidencia', 'id_incidencia', $incident_id);
    if (!$workflow) {
        incident_tracking($incident_id, INCIDENT_WORKUNIT_ADDED);
    }
    // Add work unit if enabled
    $sql = sprintf('INSERT INTO tworkunit (timestamp, duration, id_user, description, public, work_home)
			VALUES ("%s", %.2f, "%s", "%s", %d, %d)', $fecha, $timeused, $user, $wu_text, $public, $work_home);
    $id_workunit = process_sql($sql, "insert_id");
    $sql = sprintf('INSERT INTO tworkunit_incident (id_incident, id_workunit)
			VALUES (%d, %d)', $incident_id, $id_workunit);
    $res = process_sql($sql);
    if ($task_id) {
        $sql = sprintf('INSERT INTO tworkunit_task (id_task, id_workunit)
						VALUES (%d, %d)', $task_id, $id_workunit);
        $res = process_sql($sql);
    }
    if ($res !== false) {
        $email_copy_sql = 'select email_copy from tincidencia where id_incidencia =' . $incident_id . ';';
        $email_copy = get_db_sql($email_copy_sql);
        if ($send_email == 1) {
            if ($email_copy != "") {
                mail_incident($incident_id, $user, $wu_text, $timeused, 10, 7);
            }
            if ($config["email_on_incident_update"] != 2 && $config["email_on_incident_update"] != 4) {
                mail_incident($incident_id, $user, $wu_text, $timeused, 10);
            }
        }
    } else {
        //Delete workunit
        $sql = sprintf('DELETE FROM tworkunit WHERE id = %d', $id_workunit);
        return false;
    }
    return $id_workunit;
}
Beispiel #3
0
 // Delete note
 if (isset($_GET["id_nota"])) {
     $note_user = give_note_author($_GET["id_nota"]);
     if (give_acl($iduser_temp, $id_grupo, "IM") || $note_user == $iduser_temp || ($usuario = $iduser_temp)) {
         // Only admins (manage incident) or owners can modify incidents, including their notes
         // But note authors was able to delete this own notes
         $id_nota = $_GET["id_nota"];
         $id_nota_inc = $_GET["id_nota_inc"];
         $query = "DELETE FROM tnota WHERE id_nota = " . $id_nota;
         $query2 = "DELETE FROM tnota_inc WHERE id_nota_inc = " . $id_nota_inc;
         mysql_query($query);
         mysql_query($query2);
         if (mysql_query($query)) {
             $result_msg = "<h3 class='suc'>" . __('Note successfully deleted') . "</h3>";
         }
         incident_tracking($id_inc, $id_usuario, INCIDENT_NOTE_DELETED);
     }
 }
 echo "<div id='menu_tab'><ul class='mn'>";
 // Incident main
 echo "<li class='nomn'>";
 echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_detail&id={$id_inc}'><img src='images/page_white_text.png' class='top' border=0> " . __('Incident') . " </a>";
 echo "</li>";
 // Tracking
 echo "<li class='nomn'>";
 echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_tracking&id={$id_inc}'><img src='images/eye.png' class='top' border=0> " . __('Tracking') . " </a>";
 echo "</li>";
 // Workunits
 $timeused = get_incident_wokunit_hours($id_inc);
 echo "<li class='nomn'>";
 if ($timeused > 0) {
Beispiel #4
0
    $timestamp = print_mysql_timestamp();
    $sql = sprintf('INSERT INTO tincidencia
			(inicio, actualizacion, titulo, descripcion,
			id_usuario, estado, prioridad,
			id_grupo, id_creator, notify_email, id_task,
			resolution, id_incident_type, sla_disabled, email_copy, epilog)
			VALUES ("%s", "%s", "%s", "%s", "%s", %d, %d, %d, "%s",
			%d, %d, %d, %d, %d, "%s", "%s")', $timestamp, $timestamp, $title, $description, $id_user_responsible, $estado, $priority, $group_id, $id_creator, $email_notify, $id_task, $resolution, $id_incident_type, $sla_disabled, $email_copy, $epilog);
    $id = process_sql($sql, 'insert_id');
    if ($id !== false) {
        /* Update inventory objects in incident */
        update_incident_inventories($id, array($id_inventory));
        $result_msg = ui_print_success_message(__('Successfully created') . ' (id #' . $id . ')', '', true);
        $result_msg .= '<h4><a href="index.php?sec=incidents&sec2=operation/incidents_simple/incident&id=' . $id . '">' . __('Please click here to continue working with ticket #') . $id . "</a></h4>";
        audit_db($config["id_user"], $config["REMOTE_ADDR"], "Ticket created", "User " . $config['id_user'] . " created ticket #" . $id);
        incident_tracking($id, INCIDENT_CREATED);
        //Add traces and statistic information
        incidents_set_tracking($id, 'create', $priority, $estado, $resolution, $id_user_responsible, $group_id);
        // Email notify to all people involved in this incident
        if ($email_notify) {
            mail_incident($id, $id_user_responsible, "", 0, 1);
        }
        //insert data to incident type fields
        if ($id_incident_type > 0) {
            $sql_label = "SELECT `label` FROM `tincident_type_field` WHERE id_incident_type = {$id_incident_type}";
            $labels = get_db_all_rows_sql($sql_label);
            if ($labels === false) {
                $labels = array();
            }
            foreach ($labels as $label) {
                $id_incident_field = get_db_value_filter('id', 'tincident_type_field', array('id_incident_type' => $id_incident_type, 'label' => $label['label']), 'AND');
Beispiel #5
0
function api_attach_file($return_type, $user, $params)
{
    global $config;
    $id_incident = $params[0];
    if (!check_user_incident($user, $id_incident)) {
        return;
    }
    // Insert into database
    $filename = $params[1];
    $filesize = $params[2];
    $file_description = $params[3];
    $file_content = base64_decode($params[4]);
    $sql = sprintf('INSERT INTO tattachment (id_incidencia, id_usuario,
			filename, description, size)
			VALUES (%d, "%s", "%s", "%s", %d)', $id_incident, $user, $filename, $file_description, $filesize);
    $id_attachment = process_sql($sql, 'insert_id');
    $config['id_user'] = $user;
    incident_tracking($id_incident, INCIDENT_FILE_ADDED);
    /*
    	// Email notify to all people involved in this incident
    	if ($email_notify == 1) {
    		if ($config["email_on_incident_update"] == 1){
    			mail_incident ($id_incident, $user, 0, 0, 2);
    		}
    	}*/
    include_once "config.php";
    $homedir = get_db_value('value', 'tconfig', 'token', $condition = 1);
    // Copy file to directory and change name
    $short_filename = $filename;
    $filename = $config["homedir"] . "/attachment/" . $id_attachment . "_" . $filename;
    $file_handler = fopen($filename, "w");
    fputs($file_handler, $file_content);
    fclose($DescriptorFichero);
    if (!$file_handler) {
        $result = '-1';
        $sql = sprintf('DELETE FROM tattachment
				WHERE id_attachment = %d', $id_attachment);
        process_sql($sql);
    } else {
        // Adding a WU noticing about this
        $link = "<a target='_blank' href='operation/common/download_file.php?type=incident&id_attachment=" . $id_attachment . "'>" . $short_filename . "</a>";
        $nota = "Automatic WU: Added a file to this issue. Filename uploaded: " . $link;
        $public = 1;
        $timestamp = print_mysql_timestamp();
        $timeused = "0.05";
        $sql = sprintf('INSERT INTO tworkunit (timestamp, duration, id_user, description, public) VALUES ("%s", %.2f, "%s", "%s", %d)', $timestamp, $timeused, $user, $nota, $public);
        $id_workunit = process_sql($sql, "insert_id");
        $sql = sprintf('INSERT INTO tworkunit_incident (id_incident, id_workunit) VALUES (%d, %d)', $id_incident, $id_workunit);
        process_sql($sql);
        $result = '0';
    }
    switch ($return_type) {
        case "xml":
            echo xml_node($result);
            break;
        case "csv":
            echo $result;
            break;
    }
}
Beispiel #6
0
}

// Delete file
$delete_file = (bool) get_parameter ('delete_file');
if ($delete_file) {
	if (give_acl ($config['id_user'], $id_grupo, "IM")) {
		$id_attachment = get_parameter ('id_attachment');
		$filename = get_db_value ('filename', 'tattachment',
			'id_attachment', $id_attachment);
		$sql = sprintf ('DELETE FROM tattachment WHERE id_attachment = %d',
			$id_attachment);
		process_sql ($sql);
		$result_msg = '<h3 class="suc">'.__('Successfully deleted').'</h3>';
		if (!unlink ($config["homedir"].'attachment/'.$id_attachment.'_'.$filename))
			$result_msg = '<h3 class="error">'.__('Could not be deleted').'</h3>';
		incident_tracking ($id, INCIDENT_FILE_REMOVED);
		
	} else {
		$result_msg = '<h3 class="error">'.__('You have no permission').'</h3>';
	}
	
	echo $result_msg;
}

if (!$clean_output) {
	echo "<br>";
	echo "<strong>".__("File formats supported")."</strong>";
	echo print_help_tip (__("Please note that you cannot upload .php or .pl files, as well other source code formats. Please compress that files prior to upload (using zip or gz)"), true);
	
	echo "<form id=\"form-incident_files\" class=\"fileupload_form\" method=\"post\" enctype=\"multipart/form-data\">";
	echo 	"<div id=\"drop_file\" style=\"padding:0px 0px;\">";
Beispiel #7
0
                    incident_tracking($id_ticket, INCIDENT_GOLD_MEDAL_ADDED, $values['id_usuario']);
                    audit_db($config['id_user'], $config["REMOTE_ADDR"], "Gold medal added", "Gold medal added by user " . $config['id_user'] . " to the ticket #" . $id_ticket);
                    break;
                case 2:
                    //Remove gold medal
                    incident_tracking($id_ticket, INCIDENT_GOLD_MEDAL_REMOVED, $values['id_usuario']);
                    audit_db($config['id_user'], $config["REMOTE_ADDR"], "Gold medal removed", "Gold medal removed by user " . $config['id_user'] . " to the ticket #" . $id_ticket);
                    break;
                case 3:
                    //Add black medal
                    incident_tracking($id_ticket, INCIDENT_BLACK_MEDAL_ADDED, $values['id_usuario']);
                    audit_db($config['id_user'], $config["REMOTE_ADDR"], "Black medal added", "Black medal added by user " . $config['id_user'] . " to the ticket #" . $id_ticket);
                    break;
                case 4:
                    //Remove black medal
                    incident_tracking($id_ticket, INCIDENT_BLACK_MEDAL_REMOVED, $values['id_usuario']);
                    audit_db($config['id_user'], $config["REMOTE_ADDR"], "Black medal removed", "Black medal removed by user " . $config['id_user'] . " to the ticket #" . $id_ticket);
                    break;
            }
        }
        enterprise_hook("incidents_run_realtime_workflow_rules", array($id_ticket));
    }
}
if ($search_ajax) {
    $filter = array();
    $filter['inverse_filter'] = (bool) get_parameter('search_inverse_filter');
    $filter['string'] = (string) get_parameter('search_string');
    $filter['status'] = (int) get_parameter('search_status', -10);
    $filter['priority'] = (int) get_parameter('search_priority', -1);
    $filter['id_group'] = (int) get_parameter('search_id_group', 1);
    $filter['id_company'] = (int) get_parameter('search_id_company');
}
// Workunit ADD
$insert_workunit = (bool) get_parameter('insert_workunit');
if ($insert_workunit) {
    $timestamp = print_mysql_timestamp();
    $nota = get_parameter("nota");
    $timeused = (double) get_parameter('duration');
    $have_cost = (int) get_parameter('have_cost');
    $profile = (int) get_parameter('work_profile');
    $public = (bool) get_parameter('public');
    // Adding a new workunit to a incident in NEW status
    // Status go to "Assigned" and Owner is the writer of this Workunit
    if ($incident["estado"] == 1 and $incident["id_creator"] != $config['id_user']) {
        $sql = sprintf('UPDATE tincidencia SET id_usuario = "%s", estado = 3,  affected_sla_id = 0, actualizacion = "%s" WHERE id_incidencia = %d', $config['id_user'], $timestamp, $id_incident);
        incident_tracking($id_incident, INCIDENT_STATUS_CHANGED, 3);
        incident_tracking($id_incident, INCIDENT_USER_CHANGED, $config["id_user"]);
    } else {
        $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0, actualizacion = "%s" WHERE id_incidencia = %d', $timestamp, $id_incident);
    }
    process_sql($sql);
    $workunit_id = create_workunit($id_incident, $nota, $config["id_user"], $timeused, $have_cost, $profile, $public);
    if (is_ajax()) {
        // Clean the output
        // A non empty ouptput will treated as a successful response
        ob_clean();
        if ($workunit_id !== false) {
            // Return the updated list
            $workunits = get_incident_workunits($id_incident);
            if ($workunits) {
                ob_clean();
                foreach ($workunits as $workunit) {
function incidents_set_tracking($id_ticket, $action, $priority, $status, $resolution, $user, $group)
{
    switch ($action) {
        case 'update':
            $old_incident = get_incident($id_ticket);
            //Add traces and statistic information
            $tracked = false;
            if ($old_incident['prioridad'] != $priority) {
                incident_tracking($id_ticket, INCIDENT_PRIORITY_CHANGED, $priority);
                $tracked = true;
            }
            if ($old_incident['estado'] != $status) {
                incident_tracking($id_ticket, INCIDENT_STATUS_CHANGED, $status);
                $tracked = true;
            }
            if ($old_incident['resolution'] != $resolution) {
                incident_tracking($id_ticket, INCIDENT_RESOLUTION_CHANGED, $resolution);
                $tracked = true;
            }
            if ($old_incident['id_usuario'] != $user) {
                incident_tracking($id_ticket, INCIDENT_USER_CHANGED, $user);
                $tracked = true;
            }
            if ($old_incident["id_grupo"] != $group) {
                incident_tracking($id_ticket, INCIDENT_GROUP_CHANGED, $group);
                $tracked = true;
            }
            if ($tracked == false) {
                incident_tracking($id_ticket, INCIDENT_UPDATED);
            }
            break;
        case 'create':
            incident_tracking($id_ticket, INCIDENT_CREATED);
            //Add traces and statistic information
            incident_tracking($id_ticket, INCIDENT_PRIORITY_CHANGED, $priority);
            incident_tracking($id_ticket, INCIDENT_STATUS_CHANGED, $status);
            incident_tracking($id_ticket, INCIDENT_RESOLUTION_CHANGED, $resolution);
            incident_tracking($id_ticket, INCIDENT_USER_CHANGED, $user);
            incident_tracking($id_ticket, INCIDENT_GROUP_CHANGED, $group);
            break;
    }
    return;
}
Beispiel #10
0
            }
        }
        if ($config["email_on_incident_update"] != 3 && $config["email_on_incident_update"] != 4 && $values['estado'] == 7) {
            //add emails only closed
            mail_incident($id_ticket, $owner, "", 0, 5);
        } else {
            if ($config["email_on_incident_update"] == 0) {
                //add emails updates
                mail_incident($id_ticket, $owner, "", 0, 0);
            }
        }
        if ($old_incident['prioridad'] != $values['prioridad']) {
            incident_tracking($id_ticket, INCIDENT_PRIORITY_CHANGED, $values['prioridad']);
        }
        if ($old_incident['resolution'] != $values['resolution']) {
            incident_tracking($id_ticket, INCIDENT_RESOLUTION_CHANGED, $values['resolution']);
        }
        if ($old_incident['estado'] != $values['estado']) {
            if ($values['estado'] == 7) {
                $values_close['closed_by'] = $config['id_user'];
                $values_close['cierre'] = date('Y:m:d H:i:s');
                db_process_sql_update('tincidencia', $values_close, array('id_incidencia' => $id_ticket));
            }
            incident_tracking($id_ticket, INCIDENT_STATUS_CHANGED, $values['estado']);
        }
        if ($old_incident['id_usuario'] != $values['id_usuario']) {
            incident_tracking($id_ticket, INCIDENT_USER_CHANGED, $values['id_usuario']);
        }
        audit_db($old_incident['id_usuario'], $config["REMOTE_ADDR"], "Ticket updated", "User " . $config['id_user'] . " ticket updated #" . $id_ticket);
    }
}
Beispiel #11
0
 public function quickIncidentUpdate($id_incident, $type, $value)
 {
     $system = System::getInstance();
     $column = "";
     switch ($type) {
         case 'priority':
             $column = "prioridad";
             break;
         case 'owner':
             $column = "id_usuario";
             break;
         case 'resolution':
             $column = "resolution";
             break;
         case 'status':
             $column = "estado";
             break;
     }
     if ($column) {
         $res = process_sql_update('tincidencia', array($column => $value), array("id_incidencia" => $id_incident));
         if ($res && (include_once $system->getConfig('homedir') . "/include/functions_incidents.php")) {
             switch ($type) {
                 case 'priority':
                     incident_tracking($id_incident, INCIDENT_PRIORITY_CHANGED, $value);
                     break;
                 case 'owner':
                     incident_tracking($id_incident, INCIDENT_USER_CHANGED, $value);
                     break;
                 case 'resolution':
                     incident_tracking($id_incident, INCIDENT_RESOLUTION_CHANGED, $value);
                     break;
                 case 'status':
                     incident_tracking($id_incident, INCIDENT_STATUS_CHANGED, $value);
                     break;
             }
         }
     }
     return $res;
 }