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; }
$result_msg = '<h3 class="error">' . __('Creator user does not exist') . '</h3>'; } else { if ($user_exists === false) { $result_msg = '<h3 class="error">' . __('Owner user does not exist') . '</h3>'; } else { if ($id_parent == 0) { $idParentValue = null; } else { $idParentValue = sprintf('%d', $id_parent); } // 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
function api_add_address_to_newsletter($return_type, $user, $params) { global $config; if (!give_acl($user, 0, "CN")) { audit_db($user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to access newsletter management"); exit; } $values['id_newsletter'] = $params[0]; $values['name'] = $params[1]; $values['email'] = $params[2]; $values['status'] = 0; $values['datetime'] = print_mysql_timestamp(); $values['validated'] = 0; $check_id_newsletter = get_db_value("id", "tnewsletter", "id", $values['id_newsletter']); $result = 0; if (!empty($check_id_newsletter)) { $result = process_sql_insert('tnewsletter_address', $values); } switch ($return_type) { case "xml": echo xml_node($result); break; case "csv": echo $result; break; } return; }
$id = get_parameter("id"); if (! get_workorder_acl($id)) { no_permission(); } $add_note = get_parameter("addnote"); $delete = get_parameter("delete"); echo '<h1>'.__('Add a note').'</h1>'; if ($add_note) { $note = get_parameter("note"); $now = print_mysql_timestamp(); $res = workorders_insert_note ($id, $config["id_user"], $note, $now); if (! $res) echo '<h3 class="error">'.__('There was a problem creating the note').'</h3>'; else echo '<h3 class="suc">'.__('Note was added successfully').'</h3>'; } if ($delete) { $id_note = get_parameter("id_note"); $note = get_db_row ("ttodo_notes", "id", $id_note);
function inventory_tracking($id_inventory, $state, $aditional_data = 0) { global $config; if ($id_inventory == 0) { return; } switch ($state) { case INVENTORY_CREATED: $description = __('Created'); break; case INVENTORY_UPDATED: $description = __('Updated'); break; case INVENTORY_INCIDENT_ADDED: $description = __('inventory object in ticket'); $description .= " -> " . get_db_value("titulo", "tincidencia", "id_incidencia", $aditional_data); break; case 'INVENTORY_DELETED': $description = __('Deleted'); break; case INVENTORY_OWNER_CHANGED: $description = __('Owner changed') . " -> "; if ($aditional_data['old']) { $old = get_db_value("nombre_real", "tusuario", "id_usuario", $aditional_data['old']); if ($old) { $aditional_data['old'] = $old; } $description .= "Old: '" . $aditional_data['old'] . "'"; } if ($aditional_data['new']) { $new = get_db_value("nombre_real", "tusuario", "id_usuario", $aditional_data['new']); if ($new) { $aditional_data['new'] = $new; } if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_NAME_CHANGED: $description = __('Name changed') . " -> "; if ($aditional_data['old']) { $description .= "Old: '" . $aditional_data['old'] . "'"; } if ($aditional_data['new']) { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_CONTRACT_CHANGED: $description = __('Contract changed') . " -> "; if ($aditional_data['old']) { $old = get_db_value("name", "tcontract", "id", $aditional_data['old']); if ($old) { $aditional_data['old'] = $old; } $description .= "Old: '" . $aditional_data['old'] . "'"; } if ($aditional_data['new']) { $new = get_db_value("name", "tcontract", "id", $aditional_data['new']); if ($new) { $aditional_data['new'] = $new; } if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_MANUFACTURER_CHANGED: $description = __('Manufacturer changed') . " -> "; if ($aditional_data['old']) { $old = get_db_value("name", "tmanufacturer", "id", $aditional_data['old']); if ($old) { $aditional_data['old'] = $old; } $description .= "Old: '" . $aditional_data['old'] . "'"; } if ($aditional_data['new']) { $new = get_db_value("name", "tmanufacturer", "id", $aditional_data['new']); if ($new) { $aditional_data['new'] = $new; } if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_STATUS_CHANGED: $description = __('Status changed') . " -> "; if ($aditional_data['old']) { $description .= "Old: '" . __($aditional_data['old']) . "'"; } if ($aditional_data['new']) { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . __($aditional_data['new']) . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_OBJECT_TYPE_CHANGED: $description = __('Object type changed') . " -> "; if ($aditional_data['old']) { $old = get_db_value("name", "tincident_type", "id", $aditional_data['old']); if ($old) { $aditional_data['old'] = $old; } $description .= "Old: '" . $aditional_data['old'] . "'"; } if ($aditional_data['new']) { $new = get_db_value("name", "tincident_type", "id", $aditional_data['new']); if ($new) { $aditional_data['new'] = $new; } if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_RECEIPT_DATE_CHANGED: $description = __('Receipt date changed') . " -> "; if ($aditional_data['old'] && $aditional_data['old'] != '0000-00-00') { $description .= "Old: '" . __($aditional_data['old']) . "'"; } if ($aditional_data['new'] && $aditional_data['new'] != '0000-00-00') { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . __($aditional_data['new']) . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_ISSUE_DATE_CHANGED: $description = __('Removal date changed') . " -> "; if ($aditional_data['old'] && $aditional_data['old'] != '0000-00-00') { $description .= "Old: '" . __($aditional_data['old']) . "'"; } if ($aditional_data['new'] && $aditional_data['new'] != '0000-00-00') { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . __($aditional_data['new']) . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_PARENT_UPDATED: $description = __('Parent changed: ') . " -> "; $old = get_db_value("name", "tinventory", "id", $aditional_data['old']); if ($old) { $aditional_data['old'] = $old; } $description .= "Old: '" . __($aditional_data['old']) . "'"; if ($aditional_data['new']) { $new = get_db_value("name", "tinventory", "id", $aditional_data['new']); if ($new) { $aditional_data['new'] = $new; } if ($aditional_data['old']) { $description .= " - "; } $description .= "New: '" . $aditional_data['new'] . "'"; } else { if ($aditional_data['old']) { $description .= " - "; } $description .= "New: " . __('None'); } break; case INVENTORY_PARENT_CREATED: $description = __('Parent added'); $description .= " -> " . get_db_value("name", "tinventory", "id", $aditional_data); break; case INVENTORY_OBJECT_TYPE: $description = __('Inventory object type added'); $description .= " -> " . get_db_value("name", "tobject_type", "id", $aditional_data); break; case INVENTORY_PUBLIC: $description = __('Inventory set to public'); break; case INVENTORY_PRIVATE: $description = __('Inventory set to private'); break; case INVENTORY_DESCRIPTION_CHANGED: $description = __('Description changed'); break; case INVENTORY_COMPANIES_CREATED: $description = __('Companies added'); break; case INVENTORY_COMPANIES_UPDATED: $description = __('Companies updated'); break; case INVENTORY_USERS_CREATED: $description = __('Users added'); break; case INVENTORY_USERS_UPDATED: $description = __('Users updated'); break; default: $description = __('Unknown update'); break; } $fecha = print_mysql_timestamp(); audit_db($config["id_user"], $config["REMOTE_ADDR"], "Inventory updated", $description); $sql = sprintf('INSERT INTO tinventory_track (id_user, id_inventory, timestamp, state, id_aditional, description) VALUES ("%s", %d, "%s", %d, "%s", "%s")', $config['id_user'], $id_inventory, $fecha, $state, $aditional_data, $description); return process_sql($sql, 'insert_id'); }
$table->width = '100%'; $table->class = 'integria_form'; $table->colspan = array(); $table->colspan[1][0] = 6; $table->colspan[2][0] = 6; $table->data = array(); $table->size = array(); $table->style = array(); $table->style[0] = 'vertical-align: top; padding-top: 20px;'; $table->style[1] = 'vertical-align: top; padding-top: 20px;'; $table->style[2] = 'vertical-align: top;'; $table->style[3] = 'vertical-align: top;'; $table->style[4] = 'vertical-align: top;'; $table->style[5] = 'vertical-align: top;'; $table->data[0][0] = print_image('images/calendar_orange.png', true) . ' ' . print_mysql_timestamp(0, "Y-m-d"); $table->data[0][1] = print_image('images/clock_orange.png', true) . ' ' . print_mysql_timestamp(0, "H:i:s"); //$table->data[0][2] = combo_roles (1, 'id_profile', __('Profile'), true); $table->data[0][2] = print_select($roles, 'id_profile', '', '', '', '', true, false, true, __('Profile')); $table->data[0][3] = print_input_text("duration", $config["pwu_defaultime"], '', 7, 10, true, __('Time used')); $table->data[0][4] = print_checkbox('have_cost', 1, false, true, __('Have cost')); $table->data[0][5] = print_checkbox('public', 1, true, true, __('Public')); $table->data[1][0] = print_textarea('nota', 10, 70, '', "style='resize:none;'", true, __('Description')); $button = '<div style="width: 100%; text-align: right; padding-bottom: 20px;">'; $button .= '<span id="sending_data" style="display: none;">' . __('Sending data...') . '<img src="images/spinner.gif" /></span>'; $button .= print_submit_button(__('Add'), 'addnote', false, 'class="sub create"', true); $button .= print_input_hidden('insert_workunit', 1, true); $button .= print_input_hidden('id', $id_workorder, true); $button .= '</div>'; $table->data[2][0] = $button; echo '<form id="form-add-workunit" method="post" action="index.php?sec=projects&sec2=operation/workorders/wo&operation=view&tab=wu&id=' . $id_workorder . '&tab=wu">'; echo "<div style='width: 98%; padding-left: 7px;'>";
function incidents_search_result($filter, $ajax = false, $return_incidents = false, $print_result_count = false, $no_parents = false, $resolve_names = false, $report_mode = false, $csv_mode = false) { global $config; $params = ""; foreach ($filter as $key => $value) { $params .= "&search_" . $key . "=" . $value; } //Only show incident for last year if there isn't a search by dates if (!$filter['first_date'] && !$filter['last_date']) { $filter_year = $filter; $now = print_mysql_timestamp(); $year_in_seconds = 3600 * 24 * 365; $year_ago_unix = time() - $year_in_seconds; $year_ago = date("Y-m-d H:i:s", $year_ago_unix); $filter_year['first_date'] = $year_ago; $filter_year['last_date'] = $now; $count_this_year = filter_incidents($filter_year, true, false, $no_parents, $csv_mode); $aux_text = "(" . $count_this_year . ")" . print_help_tip(__("Tickets created last year"), true); } if (!$report_mode) { //Add offset to filter parameters $offset = get_parameter("offset"); $filter["offset"] = $offset; // Store the previous limit filter $limit_aux = $filter["limit"]; } // Set the limit filter to 0 to retrieve all the tickets for the array pagination $filter["limit"] = 0; // All the tickets the user sees are retrieved $incidents = filter_incidents($filter, false, true, $no_parents, $csv_mode); $count = empty($incidents) ? 0 : count($incidents); if ($resolve_names) { $incidents_aux = array(); $i = 0; foreach ($incidents as $inc) { $incidents_aux[$i] = $inc; $incidents_aux[$i]['estado'] = incidents_get_incident_status_text($inc['id_incidencia']); $incidents_aux[$i]['resolution'] = incidents_get_incident_resolution_text($inc['id_incidencia']); $incidents_aux[$i]['prioridad'] = incidents_get_incident_priority_text($inc['id_incidencia']); $incidents_aux[$i]['id_grupo'] = incidents_get_incident_group_text($inc['id_incidencia']); $incidents_aux[$i]['id_group_creator'] = incidents_get_incident_group_text($inc['id_incidencia']); //~ $incidents_aux[$i]['id_incident_type'] = incidents_get_incident_type_text ($inc['id_incidencia']); $i++; } $incidents = $incidents_aux; } if ($return_incidents) { return $incidents; } if (!$report_mode) { // Set the limit filter to its previous value $filter["limit"] = $limit_aux; $url = "index.php?sec=incidents&sec2=operation/incidents/incident_search" . $params; $incidents = print_array_pagination($incidents, $url, $offset); } $statuses = get_indicent_status(); $resolutions = get_incident_resolutions(); // ORDER BY if ($filter['order_by'] && !is_array($filter['order_by'])) { $order_by = json_decode(clean_output($filter['order_by']), true); } else { $order_by = $filter['order_by']; } if (!$report_mode) { if ($order_by["id_incidencia"] != "") { if ($order_by["id_incidencia"] == "DESC") { $id_order_image = " <a href='javascript:changeIncidentOrder(\"id_incidencia\", \"ASC\")'><img src='images/arrow_down_orange.png'></a>"; } else { $id_order_image = " <a href='javascript:changeIncidentOrder(\"id_incidencia\", \"\")'><img src='images/arrow_up_orange.png'></a>"; } } else { $id_order_image = " <a href='javascript:changeIncidentOrder(\"id_incidencia\", \"DESC\")'><img src='images/block_orange.png'></a>"; } if ($order_by["prioridad"] != "") { if ($order_by["prioridad"] == "DESC") { $priority_order_image = " <a href='javascript:changeIncidentOrder(\"prioridad\", \"ASC\")'><img src='images/arrow_down_orange.png'></a>"; } else { $priority_order_image = " <a href='javascript:changeIncidentOrder(\"prioridad\", \"\")'><img src='images/arrow_up_orange.png'></a>"; } } else { $priority_order_image = " <a href='javascript:changeIncidentOrder(\"prioridad\", \"DESC\")'><img src='images/block_orange.png'></a>"; } } else { $id_order_image = ""; $priority_order_image = ""; } // ---------------------------------------- // Here we print the result of the search // ---------------------------------------- echo '<table width="99%" cellpadding="0" cellspacing="0" border="0px" class="result_table listing" id="incident_search_result_table">'; echo '<thead>'; echo "<tr>"; echo "<th>"; echo print_checkbox('incidentcb-all', "", false, true); echo "</th>"; echo "<th>"; echo __('ID') . $id_order_image; echo "</th>"; echo "<th>"; echo __('SLA'); echo "</th>"; if ($report_mode) { echo "<th>"; echo __(' % SLA'); echo "</th>"; } echo "<th>"; echo __('Ticket'); echo "</th>"; echo "<th>"; echo __('Group') . "<br><i>" . __('Company') . "</i>"; echo "</th>"; echo "<th>"; echo __('Status') . "<br><i>" . __('Resolution') . "</i>"; echo "</th>"; echo "<th>"; echo __('Priority') . $priority_order_image; echo "</th>"; echo "<th style='width: 70px;'>"; echo __('Updated') . "<br><i>" . __('Started') . "</i>"; echo "</th>"; if ($config["show_creator_incident"] == 1) { echo "<th>"; } echo __('Creator'); echo "</th>"; if ($config["show_owner_incident"] == 1) { echo "<th>"; } echo __('Owner'); echo "</th>"; echo "</tr>"; echo '</thead>'; echo "<tbody>"; if ($incidents == false) { echo '<tr><td colspan="11">' . __('Nothing was found') . '</td></tr>'; } else { foreach ($incidents as $incident) { /* We print the rows directly, because it will be used in a sortable jQuery table and it only needs the rows */ if ($incident["estado"] < 3) { $tr_status = 'class="red_row"'; } elseif ($incident["estado"] < 6) { $tr_status = 'class="yellow_row"'; } else { $tr_status = 'class="green_row"'; } echo '<tr ' . $tr_status . ' id="incident-' . $incident['id_incidencia'] . '"'; echo " style='border-bottom: 1px solid #ccc;' >"; echo '<td>'; print_checkbox_extended('incidentcb-' . $incident['id_incidencia'], $incident['id_incidencia'], false, '', '', 'class="cb_incident"'); echo '</td>'; //Print incident link if not ajax, if ajax link to js funtion to replace parent $link = "index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=" . $incident["id_incidencia"]; if ($ajax) { $link = "javascript:update_parent('" . $incident["id_incidencia"] . "')"; } echo '<td>'; if (!$report_mode) { echo '<strong><a href="' . $link . '">#' . $incident['id_incidencia'] . '</a></strong></td>'; } else { echo '<strong>' . '#' . $incident['id_incidencia'] . '</strong></td>'; } // SLA Fired ?? if ($incident["affected_sla_id"] != 0) { echo '<td width="25"><img src="images/exclamation.png" /></td>'; } else { echo '<td></td>'; } // % SLA if ($report_mode) { echo "<td>"; if ($incident["affected_sla_id"] != 0) { echo format_numeric(get_sla_compliance_single_id($incident['id_incidencia'])); } else { echo ""; } echo "</td>"; } echo '<td>'; if (!$report_mode) { echo '<strong><a href="' . $link . '">' . $incident['titulo'] . '</a></strong><br>'; } else { echo '<strong>' . $incident['titulo'] . '</strong><br>'; } echo "<span style='font-size:11px;font-style:italic'>"; echo incidents_get_incident_type_text($incident["id_incidencia"]); // Added by slerena 26Ago2013 $sql = sprintf("SELECT *\n\t\t\t\t\t\t\tFROM tincident_type_field\n\t\t\t\t\t\t\tWHERE id_incident_type = %d", $incident["id_incident_type"]); $config['mysql_result_type'] = MYSQL_ASSOC; $type_fields = get_db_all_rows_sql($sql); $type_fields_values_text = ""; if ($type_fields) { foreach ($type_fields as $type_field) { if ($type_field["show_in_list"]) { $field_data = get_db_value_filter("data", "tincident_field_data", array("id_incident" => $incident["id_incidencia"], "id_incident_field" => $type_field["id"])); if ($field_data) { if ($type_field["type"] == "textarea") { $field_data = "<div style='display: inline-block;' title='{$field_data}'>" . substr($field_data, 0, 15) . "...</div>"; } $type_fields_values_text .= " <div title='" . $type_field["label"] . "' style='display: inline-block;'>[{$field_data}]</div>"; } } } } echo " {$type_fields_values_text}"; echo '</span></td>'; echo '<td>' . get_db_value("nombre", "tgrupo", "id_grupo", $incident['id_grupo']); if ($config["show_creator_incident"] == 1) { $id_creator_company = get_db_value("id_company", "tusuario", "id_usuario", $incident["id_creator"]); if ($id_creator_company != 0) { $company_name = (string) get_db_value('name', 'tcompany', 'id', $id_creator_company); echo "<br><span style='font-size:11px;font-style:italic'>{$company_name}</span>"; } } echo '</td>'; $resolution = isset($resolutions[$incident['resolution']]) ? $resolutions[$incident['resolution']] : __('None'); echo '<td class="f9"><strong>' . $statuses[$incident['estado']] . '</strong><br /><em>' . $resolution . '</em></td>'; // priority echo '<td>'; print_priority_flag_image($incident['prioridad']); $last_wu = get_incident_lastworkunit($incident["id_incidencia"]); if ($last_wu["id_user"] == $incident["id_creator"]) { echo "<br><img src='images/comment.gif' title='" . $last_wu["id_user"] . "'>"; } echo '</td>'; echo '<td style="font-size:11px;">' . human_time_comparation($incident["actualizacion"]); // Show only if it's different if ($incident["inicio"] != $incident["actualizacion"]) { echo "<br><em>[" . human_time_comparation($incident["inicio"]); echo "]</em>"; } echo "<br>"; echo '<span style="font-size:9px;">'; if (isset($config["show_user_name"]) && $config["show_user_name"]) { $updated_by = get_db_value('nombre_real', 'tusuario', 'id_usuario', $last_wu["id_user"]); } else { $updated_by = $last_wu["id_user"]; } echo $updated_by; echo "</span>"; echo '</td>'; if ($config["show_creator_incident"] == 1) { echo "<td class='f9'>"; if (isset($config["show_user_name"]) && $config["show_user_name"]) { $incident_creator = get_db_value('nombre_real', 'tusuario', 'id_usuario', $incident["id_creator"]); } else { $incident_creator = $incident["id_creator"]; } //~ echo substr($incident_creator,0,12); echo $incident_creator; echo "</td>"; } if ($config["show_owner_incident"] == 1) { echo "<td class='f9'>"; if (isset($config["show_user_name"]) && $config["show_user_name"]) { $incident_owner = get_db_value('nombre_real', 'tusuario', 'id_usuario', $incident["id_usuario"]); } else { $incident_owner = $incident["id_usuario"]; } echo $incident_owner; echo "</td>"; } echo '</tr>'; } } echo "</tbody>"; echo "</table>"; if (!$report_mode) { pagination($count, $url, $offset, false, $aux_text); } if ($print_result_count) { echo "<h5>" . $count . __(" ticket(s) found") . "</h5>"; } echo "<br>"; }
public function insertIncident($title, $description, $group_id, $id_creator = "", $status = 1, $priority = 2, $resolution = 0, $id_task = 0, $sla_disabled = 0, $id_incident_type = 0, $email_copy = "", $email_notify = -1, $id_parent = 0, $epilog = "") { $system = System::getInstance(); if ($id_creator == "") { $id_creator = $system->getConfig('id_user'); } if ($email_notify == -1) { $email_notify = get_db_value("forced_email", "tgrupo", "id_grupo", $group_id); } if ($id_parent == 0) { $idParentValue = 'NULL'; } else { $idParentValue = sprintf('%d', $id_parent); } $user_responsible = get_group_default_user($group_id); $id_user_responsible = $user_responsible['id_usuario']; if ($id_user_responsible === false) { $id_user_responsible = $system->getConfig('id_user'); } $id_inventory = get_group_default_inventory($group_id, true); // DONT use MySQL NOW() or UNIXTIME_NOW() because // Integria can override localtime zone by a user-specified timezone. $timestamp = print_mysql_timestamp(); $sql = "INSERT INTO tincidencia\n\t\t\t\t(inicio, actualizacion, titulo, descripcion, id_usuario,\n\t\t\t\testado, prioridad, id_grupo, id_creator, notify_email, id_task,\n\t\t\t\tresolution, id_incident_type, sla_disabled, email_copy, epilog)\n\t\t\t\tVALUES ('{$timestamp}', '{$timestamp}', '{$title}', '{$description}',\n\t\t\t\t'{$id_user_responsible}', {$status}, {$priority}, {$group_id}, '{$id_creator}',\n\t\t\t\t{$email_notify}, {$id_task}, {$resolution}, {$id_incident_type}, {$sla_disabled},\n\t\t\t\t'{$email_copy}', '{$epilog}')"; $id_incident = process_sql($sql, 'insert_id'); if ($id_incident !== false) { if (include_once $system->getConfig('homedir') . "/include/functions_incidents.php") { /* Update inventory objects in incident */ update_incident_inventories($id_incident, array($id_inventory)); } audit_db($config["id_user"], $config["REMOTE_ADDR"], "Ticket created", "User " . $config['id_user'] . " created ticket #" . $id_incident); incident_tracking($id_incident, INCIDENT_CREATED); // Email notify to all people involved in this incident if ($email_notify) { mail_incident($id_incident, $usuario, "", 0, 1); } // Insert data of 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_incident; $values_insert['data'] = $system->getRequest(base64_encode($label['label'])); $values_insert['id_incident_field'] = $id_incident_field; $id_incident_field = get_db_value('id', 'tincident_type_field', 'id_incident_type', $id_incident_type); process_sql_insert('tincident_field_data', $values_insert); } } return $id_incident; } }
function api_add_address_to_newsletter($return_type, $user, $params) { global $config; if (!give_acl($user, 0, "CN")) { audit_db($user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to access newsletter management"); exit; } $values['id_newsletter'] = $params[0]; $values['name'] = $params[1]; $values['email'] = $params[2]; $values['status'] = 0; $values['datetime'] = print_mysql_timestamp(); $values['validated'] = 0; $result = process_sql_insert('tnewsletter_address', $values); echo $result; return; }
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 = str_replace(" ", "_", $params[1]); $filesize = $params[2]; $file_description = $params[3]; $file_content = base64_decode(str_replace(" ", "+", $params[4])); //Check if file exists $exists = get_db_value_sql("SELECT id_attachment FROM tattachment WHERE id_incidencia=" . $id_incident . " AND filename='" . $filename . "'"); if ($exists) { $result = '0'; echo $result; return; } $sql = sprintf('INSERT INTO tattachment (id_incidencia, id_usuario, filename, description, size, timestamp) VALUES (%d, "%s", "%s", "%s", %d, "%s")', $id_incident, $user, $filename, $file_description, $filesize, date("Y-m-d H:i:s")); $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); $close = fclose($file_handler); 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; } }