(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'); $values_insert['id_incident'] = $id; $values_insert['data'] = get_parameter(base64_encode($label['label']));
// DONT use MySQL NOW() or UNIXTIME_NOW() because // Integria can override localtime zone by a user-specified timezone. if ($config["change_incident_datetime"] && $creation_date && $creation_time) { $timestamp = "{$creation_date} {$creation_time}"; } else { $timestamp = print_mysql_timestamp(); } $values = array('inicio' => $timestamp, 'actualizacion' => $timestamp, 'titulo' => $titulo, 'descripcion' => $description, 'id_usuario' => $usuario, 'closed_by' => $closed_by, 'estado' => $estado, 'prioridad' => $priority, 'id_grupo' => $grupo, 'id_creator' => $id_creator, 'notify_email' => $email_notify, 'id_task' => $id_task, 'resolution' => $resolution, 'id_incident_type' => $id_incident_type, 'id_parent' => $idParentValue, 'sla_disabled' => $sla_disabled, 'email_copy' => $email_copy, 'editor' => $editor, 'id_group_creator' => $id_group_creator, 'blocked' => $blocked, 'old_status' => $old_status, 'old_resolution' => $old_resolution); $id = process_sql_insert('tincidencia', $values); if ($id !== false) { /* Update inventory objects in incident */ update_incident_inventories($id, get_parameter('inventories')); $result_msg = '<h3 class="suc">' . __('Successfully created') . ' (id #' . $id . ')</h3>'; $result_msg .= '<h4><a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $id . '">' . __('Please click here to continue working with incident #') . $id . "</a></h4>"; //Add traces and statistic information incidents_set_tracking($id, 'create', $priority, $estado, $resolution, $usuario, $grupo); audit_db($config["id_user"], $config["REMOTE_ADDR"], "Ticket created", "User " . $config['id_user'] . " created incident #" . $id); // Create automatically a WU with the editor ? if ($config["incident_creation_wu"] == 1) { $wu_text = __("WU automatically created by the editor on the incident creation."); // Do not send mail in this WU create_workunit($id, $wu_text, $editor, $config["iwu_defaultime"], 0, "", 1, 0); } // Email notify to all people involved in this incident if ($email_notify) { mail_incident($id, $usuario, "", 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);
function api_update_incident($return_type, $user, $params) { $id_incident = $params[0]; $values['titulo'] = $params[1]; // Check if user and title is not empty and user exists if (empty($values['titulo'])) { return; } if (!check_user_incident($user, $id_incident)) { return; } $timestamp = print_mysql_timestamp(); $values['descripcion'] = $params[2]; $values['epilog'] = $params[3]; $values['id_grupo'] = $params[4]; $values['prioridad'] = $params[5]; $values['resolution'] = $params[6]; $values['estado'] = $params[7]; $values['id_usuario'] = $params[8]; $id_parent = $params[9]; if ($id_parent != 0 && $id_parent != '') { $values['id_parent'] = $params[9]; } $values['id_incident_type'] = $params[10]; $values['extra_data'] = $params[11]; $values['extra_data2'] = $params[12]; $values['actualizacion'] = $timestamp; if ($values['estado'] == 7) { $values['cierre'] = $timestamp; } $id_incident_type = $values['id_incident_type']; $old_incident = get_incident($id_incident); if (!$old_incident['old_status2']) { $values['old_status'] = $old_incident["old_status"]; $values['old_resolution'] = $old_incident["old_resolution"]; $values['old_status2'] = $values['estado']; $values['old_resolution2'] = $values['resolution']; } else { if ($old_incident['old_status2'] == $values['estado'] && $old_incident['old_resolution2'] == $values['resolution']) { $values['old_status'] = $old_incident["old_status"]; $values['old_resolution'] = $old_incident["old_resolution"]; $values['old_status2'] = $old_incident["old_status2"]; $values['old_resolution2'] = $old_incident["old_resolution2"]; } else { $values['old_status'] = $old_incident["old_status2"]; $values['old_resolution'] = $old_incident["old_resolution2"]; $values['old_status2'] = $values['estado']; $values['old_resolution2'] = $values['resolution']; } } $old_status = api_get_status_incident($id_incident); $values['old_status'] = $old_status; $old_resolution = api_get_resolution_incident($id_incident); $values['old_resolution'] = $old_resolution; $new_status = $values['estado']; $check_status = enterprise_hook("incidents_check_allowed_status", array($old_status, $new_status, false, true, true, $old_resolution)); if ($check_status == ENTERPRISE_NOT_HOOK) { $check_status = true; } if ($values['estado'] == STATUS_CLOSED) { //~ $check_resolution = enterprise_hook("incidents_check_allowed_resolution", array($resolution, $values['estado'], $id_incident, true)); $check_resolution = enterprise_hook("incidents_check_allowed_resolution", array($values['resolution'], $values['estado'], $id_incident, true)); if ($check_resolution == ENTERPRISE_NOT_HOOK) { $check_resolution = true; } } else { $check_resolution = true; //~ $enterprise = enterprise_hook("incidents_check_allowed_resolution", array($resolution, $values['estado'], $id_incident, true)); $enterprise = enterprise_hook("incidents_check_allowed_resolution", array($values['resolution'], $values['estado'], $id_incident, true)); if ($enterprise != ENTERPRISE_NOT_HOOK) { $values['resolution'] = 0; } } if ($check_status && $check_resolution) { $result = process_sql_update('tincidencia', $values, array('id_incidencia' => $id_incident)); //Add traces and statistic information incidents_set_tracking($id_incident, 'update', $values['prioridad'], $values['estado'], $values['resolution'], $user, $values['id_grupo']); //Add only update info incident_tracking($id_incident, INCIDENT_UPDATED); if ($id_incident_type != 0) { //in the massive operations no change id_incident_type $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(); } $num_params = 13; foreach ($labels as $label) { $values_type_field['data'] = $params[$num_params]; $id_incident_field = get_db_value_filter('id', 'tincident_type_field', array('id_incident_type' => $id_incident_type, 'label' => $label['label']), 'AND'); $values_type_field['id_incident_field'] = $id_incident_field; $values_type_field['id_incident'] = $id_incident; $exists_id = get_db_value_filter('id', 'tincident_field_data', array('id_incident' => $id_incident, 'id_incident_field' => $id_incident_field), 'AND'); if ($exists_id) { process_sql_update('tincident_field_data', $values_type_field, array('id_incident_field' => $id_incident_field, 'id_incident' => $id_incident), 'AND'); } else { process_sql_insert('tincident_field_data', $values_type_field); } $num_params++; } } switch ($return_type) { case "xml": echo xml_node($result); break; case "csv": echo $result; break; } } }