= 0) //-1 = All $filter .= sprintf (" AND estado = %d", $estado); $grupo = (int) get_parameter ("grupo", 0); if ($grupo > 0) { $filter .= sprintf (" AND id_grupo = %d", $grupo); if (check_acl ($config['id_user'], $grupo, "IM") == 0) { db_pandora_audit("ACL Forbidden","User tried to read incidents from group without access"); include ("general/noaccess.php"); exit; } } $prioridad = (int) get_parameter ("prioridad", -1); if ($prioridad != -1) //-1 = All $filter .= sprintf (" AND prioridad = %d", $prioridad); $agent_search = (int) get_parameter("agent_search"); if ($agent_search != 0){ $filter .= sprintf(" AND id_agent = %d", $agent_search); } $offset = (int) get_parameter ("offset", 0); $groups = users_get_groups ($config["id_user"], "IR"); //Select incidencts where the user has access to ($groups from //get_user_groups), array_keys for the id, implode to pass to SQL switch ($config["dbtype"]) { case "mysql": $sql = "SELECT * FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($groups)).")".$filter." ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"]; $count_sql = "SELECT count(*) FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($groups)).")".$filter." ORDER BY actualizacion DESC"; break; case "postgresql": case "oracle": $sql = "SELECT * FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($groups)).")".$filter." ORDER BY actualizacion DESC OFFSET ".$offset." LIMIT ".$config["block_size"]; $count_sql = "SELECT count(*) FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($groups)).")".$filter; break; } $result = db_get_all_rows_sql ($sql); $count = db_get_value_sql ($count_sql); if (empty ($result)) { $result = array (); $count = 0; } echo '
'; echo '

'.__('Filter').'

'; $fields = incidents_get_status (); html_print_select ($fields, "estado", $estado, 'javascript:this.form.submit();', __('All incidents'), -1, false, false, false, 'w155'); //Legend echo '

'.__('Status').'

'; foreach (incidents_get_status () as $id => $str) { incidents_print_status_img ($id); echo ' - ' . $str . '
'; } echo '

'.__('Priority').'

'; foreach (incidents_get_priorities () as $id => $str) { incidents_print_priority_img ($id); echo ' - ' . $str . '
'; } echo '
'; $fields = incidents_get_priorities (); html_print_select ($fields, "prioridad", $prioridad, 'javascript:this.form.submit();', __('All priorities'), -1,false,false,false,'w155'); echo '
'; html_print_select (users_get_info (), "usuario", $usuario, 'javascript:this.form.submit();', __('All users'), "", false, false, false, "w155"); echo '
'; $agents_incidents = agents_get_agents(false, array('id_agente', 'nombre')); if ($agents_incidents === false){ $agents_incidents = array(); } $result_agent_incidents = array(); foreach ($agents_incidents as $agent_incident) { $result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre']; } html_print_select ($result_agent_incidents, "agent_search", $agent_search, 'javascript:this.form.submit();', __('All agents'), "", false, false, false, "w155"); echo '
'; html_print_select_groups($config["id_user"], "IR", true, "grupo", $grupo, 'javascript:this.form.submit();', '', '',false,false,false,'w155'); echo "    "; html_print_input_text ('texto', $texto, '', 45); echo ' '; html_print_input_image ("submit", "images/zoom.png", __('Search'), 'padding:0;', false, array ("alt" => __('Search'))); echo "
"; echo '
'; if ($count < 1) { echo '
'.__('No incidents match your search filter').'

'; } else { // TOTAL incidents $url = "index.php?sec=workspace&sec2=operation/incidents/incident"; $estado = -1; // add form filter values for group, priority, state, and search fields: user and text if ($grupo != -1) $url .= "&grupo=".$grupo; if ($prioridad != -1) $url .= "&prioridad=".$prioridad; if ($estado != -1) $url .= "&estado=".$estado; if ($usuario != '') $url .= "&usuario=".$usuario; if ($texto != '') $url .= "&texto=".$texto; // Show pagination ui_pagination ($count, $url, $offset, 0, false); //($count + $offset) it's real count of incidents because it's use LIMIT $offset in query. echo '
'; // Show headers $table->width = "100%"; $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] = __('Status'); $table->head[2] = __('Incident'); $table->head[3] = __('Priority'); $table->head[4] = __('Group'); $table->head[5] = __('Updated'); $table->head[6] = __('Source'); $table->head[7] = __('Owner'); $table->head[8] = __('Action'); $table->size[0] = 43; $table->size[7] = 50; $table->align[1] = "center"; $table->align[3] = "center"; $table->align[4] = "center"; $table->align[8] = "center"; $rowPair = true; $iterator = 0; foreach ($result as $row) { if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; else $table->rowclass[$iterator] = 'rowOdd'; $rowPair = !$rowPair; $iterator++; $data = array(); $data[0] = ''.$row["id_incidencia"].''; $attach = incidents_get_attach ($row["id_incidencia"]); if (!empty ($attach)) $data[0] .= '  '.html_print_image ("images/attachment.png", true, array ("style" => "align:middle;")); $data[1] = incidents_print_status_img ($row["estado"], true); $data[2] = '' . ui_print_truncate_text(io_safe_output($row["titulo"]), 'item_title').''; $data[3] = incidents_print_priority_img ($row["prioridad"], true); $data[4] = ui_print_group_icon ($row["id_grupo"], true); $data[5] = ui_print_timestamp ($row["actualizacion"], true); $data[6] = $row["origen"]; if (empty($row["id_usuario"])) { $data[7] = 'SYSTEM'; } else { $data[7] = ui_print_username ($row["id_usuario"], true); } if (check_acl ($config["id_user"], $row["id_grupo"], "IM") || $config["id_user"] == $row["id_usuario"] || $config["id_user"] == $row["id_creator"]) { $data[8] = html_print_checkbox ("id_inc[]", $row["id_incidencia"], false, true); } else { $data[8] = ''; } array_push ($table->data, $data); } echo '
'; html_print_table ($table); echo '
'; echo ''.__('Action').': ' ; if (check_acl ($config["id_user"], 0, "IW")) { html_print_submit_button (__('Delete incidents'), 'delete_btn', false, 'class="sub delete"'); } if (check_acl ($config["id_user"], 0, "IM")) { html_print_submit_button (__('Become owner'), 'own_btn', false, 'class="sub upd"'); } echo '
'; echo '
'; unset ($table); } echo '

'; if (check_acl ($config["id_user"], 0, "IW")) { echo '
'; echo '
'; html_print_submit_button (__('Create incident'), 'crt', false, 'class="sub next"'); echo '
'; echo '
'; } echo '
 
'; ?>