function incidents_search_result_group_by_project($filter, $ajax = false, $return_incidents = false, $print_result_count = false) { global $config; // ---------------------------------------- // 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'); echo "</th>"; 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'); 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>"; $tasks_in_tickets = incidents_get_filter_tickets_tree($filter, 'tasks'); if ($tasks_in_tickets === false) { $tasks_in_tickets = array(); } $i = 0; $tickets_str = ''; $add_no_project = false; foreach ($tasks_in_tickets as $task_ticket) { if ($i == 0) { $tickets_str = $task_ticket['id_task']; } else { $tickets_str .= ',' . $task_ticket['id_task']; } if ($task_ticket['id_task'] == 0) { $add_no_project = true; } $i++; } if (!empty($tasks_in_tickets)) { $sql = "SELECT t1.name as n_task, t2.name as n_project, t1.id as id_task FROM ttask t1, tproject t2\n\t\t\tWHERE t1.id_project=t2.id AND t1.id IN ({$tickets_str})\n\t\t\tORDER BY t2.name"; $tickets = get_db_all_rows_sql($sql); } else { $tickets = false; } if ($tickets === false) { $tickets = array(); } if ($add_no_project) { $tickets[$i]['id_task'] = 0; $tickets[$i]['n_project'] = __('No associated project'); } foreach ($tickets as $task_ticket) { $task = get_db_row('ttask', 'id', $task_ticket['id_task']); $img = print_image("images/input_create.png", true, array("style" => 'vertical-align: middle;', "id" => $img_id)); $img_task = print_image("images/task.png", true, array("style" => 'vertical-align: middle;')); //tickets in task $filter['id_task'] = $task_ticket['id_task']; $tickets_in_task = incidents_get_filter_tickets_tree($filter, 'tickets'); $count_tickets = count($tickets_in_task); //print ticket with task if ($task_ticket['id_task'] != 0) { $project_name = $task_ticket['n_project'] . ' - ' . $task_ticket['n_task']; } else { $project_name = $task_ticket['n_project']; } //print project-task echo '<tr><td colspan="10" valign="top">'; echo "\n\t\t<a onfocus='JavaScript: this.blur()' href='javascript: check_rows(\"" . $task_ticket['id_task'] . "\")'>" . $img . " " . $img_task . " " . safe_output($project_name) . " " . "({$count_tickets})" . "</a>" . " "; echo '</td></tr>'; foreach ($tickets_in_task as $incident) { $class = $task_ticket['id_task'] . "-task"; $tr_status = 'class="' . $class . '"'; if ($incident["estado"] < 3) { $tr_status = 'class="red_row ' . $class . '"'; } elseif ($incident["estado"] < 6) { $tr_status = 'class="yellow_row ' . $class . '"'; } else { $tr_status = 'class="green_row ' . $class . '"'; } 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>'; echo '<strong><a href="' . $link . '">#' . $incident['id_incidencia'] . '</a></strong></td>'; // SLA Fired ?? if ($incident["affected_sla_id"] != 0) { echo '<td width="25"><img src="images/exclamation.png" /></td>'; } else { echo '<td></td>'; } echo '<td>'; echo '<strong><a href="' . $link . '">' . $incident['titulo'] . '</a></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 $last_wu["id_user"]; echo $updated_by; echo "</span>"; echo '</td>'; if ($config["show_creator_incident"] == 1) { echo "<td class='f9'>"; $incident_creator = $incident["id_creator"]; echo substr($incident_creator, 0, 12); echo "</td>"; } if ($config["show_owner_incident"] == 1) { echo "<td class='f9'>"; $incident_owner = $incident["id_usuario"]; echo substr($incident_owner, 0, 12); echo "</td>"; } echo '</tr>'; } } echo '</tbody>'; echo '</table>'; }
function check_incident_sla_min_response($id_incident) { $incident = get_incident($id_incident); $sla_info = incidents_get_sla_info($incident['id_grupo']); if ($sla_info != false) { $id_sla_type = $sla_info['id_sla_type']; switch ($id_sla_type) { case 0: //NORMAL SLA /* If closed, disable any affected SLA */ if ($incident['estado'] == 6 || $incident['estado'] == 7) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; case 1: //THIRD PARTY SLA /* If closed, disable any affected SLA */ if ($incident['estado'] != 6) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; case 2: //NORMAL SLA AND THIRD PARTY SLA if ($incident['estado'] == 7) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; } } $slas = incidents_get_incident_slas($id_incident, false); $start = strtotime($incident['inicio']); $now = time(); /* Check wheter it was updated before, so there's no need to check SLA */ $update = strtotime($incident['actualizacion']); // Check SLA here. foreach ($slas as $sla) { if ($now < $start + $sla['min_response'] * 3600) { continue; } // Incident owner is the last workunit author ?, then SKIP $last_wu = get_incident_lastworkunit($id_incident); if ($last_wu && $last_wu["id_user"] != $incident["id_creator"]) { return false; } if ($last_wu["timestamp"] != "") { $last_wu_time = strtotime($last_wu['timestamp']); if ($now < $last_wu_time + $sla['min_response'] * 3600) { continue; } } // Datetime/Time check when exists (version compatibility code), this // was added as a 3.0 post-feature :-) if (isset($sla["five_daysonly"]) || isset($sla["no_holidays"])) { $dow = date("w", time()); $hod = date("G", time()); // Skip if we're on weekend if ($sla["five_daysonly"] == 1 and ($dow == 0 or $dow == 6)) { continue; } //Check if holidays enabled and today is holidays $datecalc = date("Y-m-d", time()) . ' 00:00:00'; if ($sla["no_holidays"] == 1 and is_holidays($datecalc)) { continue; } // Skip if we're out of job time if ($sla["time_from"] != $sla["time_to"]) { if ($sla["time_from"] > $hod or $sla["time_to"] < $hod) { continue; } } } // Seems that we need to fire the SLA :( $sql = sprintf('UPDATE tincidencia SET affected_sla_id = %d WHERE id_incidencia = %d', $sla['id'], $id_incident); process_sql($sql); /* SLA has been fired */ return $sla['id']; } // No SLA fired. return false; }
} while ($row_2 = mysql_fetch_array($result_2)) { $idi = $row_2["id_incidencia"]; $incidents_home .= "<tr><td>"; $incidents_home .= render_status($row_2["estado"]); $incidents_home .= "<td>"; $incidents_home .= print_priority_flag_image($row_2['prioridad'], true); $incidents_home .= "<td>"; $incidents_home .= human_time_comparation($row_2["actualizacion"]); $incidents_home .= "<td>"; $incidents_home .= "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id={$idi}'>"; $incidents_home .= $row_2["titulo"]; $incidents_home .= "</b></a>"; $incidents_home .= "</td>"; $incidents_home .= "<td style='font-size: 10px'>"; $last_wu = get_incident_lastworkunit($idi); $incidents_home .= $last_wu["id_user"]; $incidents_home .= "</td></tr>"; } if (isset($row_2)) { $incidents_home .= "</table>"; } } else { $incidents_home .= "<div class='landing_empty'>"; $incidents_home .= __("There aren't active incidents"); $incidents_home .= "</div>"; } $much_more = "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_dashboard'>"; $much_more .= "<img class='much_more' src='images/add.png' title='" . __('Incidents') . "'>"; $much_more .= "</a>"; $subtitle = "<span class='landing_subtitle'>";