'.__('Incident successfully deleted').''; audit_db ($usuario,$REMOTE_ADDR,"Incident deleted","User ".$config['id_user']." deleted incident #".$id_inc); } else { audit_db ($usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." tried to delete incident"); echo '

'.__('There was a problem deleting incident').'

'; no_permission (); } } } // UPDATE incident if ((isset ($_GET["action"])) AND ($_GET["action"] == "update")) { $id_inc = get_parameter_post ("id_inc"); $usuario = give_incident_author ($id_inc); $grupo = get_parameter_post ("grupo_form"); if (give_acl ($config['id_user'], $grupo, "IM") || $usuario == $config['id_user']) { // Only admins (manage incident) or owners can modify incidents $titulo = get_parameter_post ("titulo"); $descripcion = get_parameter_post ("descripcion"); $origen = get_parameter_post ("origen_form"); $prioridad = get_parameter_post ("prioridad_form"); $estado = get_parameter_post ("estado_form"); $ahora = date ("Y/m/d H:i:s"); $sql = sprintf ("UPDATE tincidencia SET actualizacion = '%s', titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s' WHERE id_incidencia = %d", $ahora, $titulo, $origen, $estado, $grupo, $usuario, $prioridad, $descripcion, $id_inc); $result = process_sql ($sql); if ($result !== false) { audit_db($usuario,$REMOTE_ADDR,"Incident updated","User ".$config['id_user']." updated incident #".$id_inc); echo '

'.__('Incident successfully updated').'

'; } else { echo '

'.__('There was a problem updating the incident').'

'; } } else { audit_db ($usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$config['id_user']." try to update incident"); no_permission(); } } // INSERT incident if ((isset ($_GET["action"])) AND ($_GET["action"] == "insert")) { $grupo = get_parameter_post ("grupo_form", 1); if (give_acl ($config['id_user'], $grupo, "IM")) { // Read input variables $titulo = get_parameter_post ("titulo"); $descripcion = get_parameter_post ("descripcion"); $origen = get_parameter_post ("origen_form"); $prioridad = get_parameter_post ("prioridad_form"); $id_creator = $config['id_user']; $estado = get_parameter_post ("estado_form"); $sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator) VALUES (NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s')", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"]); $id_inc = process_sql ($sql, "insert_id"); if ($id_inc === false) { echo '

'.__('Error creating incident').'

'; } else { audit_db ($config["id_user"], $REMOTE_ADDR, "Incident created", "User ".$config["id_user"]." created incident #".$id_inc); } } else { audit_db ($config["id_user"],$REMOTE_ADDR,"ACL Forbidden","User tried to create incident"); no_permission (); } } // Search $filter = ""; $texto = (string) get_parameter ("texto", ""); if ($texto != "") $filter .= sprintf (" AND (titulo LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $texto, $texto); $usuario = (string) get_parameter ("usuario", "All"); if ($usuario != "All") $filter .= sprintf (" AND id_usuario = '%s'", $usuario); $estado = (int) get_parameter ("estado", -1); if ($estado != -1) //-1 = All $filter .= sprintf (" AND estado = %d", $estado); $grupo = (int) get_parameter ("grupo", 1); if ($grupo != 1) { $filter .= sprintf (" AND id_grupo = %d", $grupo); if (give_acl ($config['id_user'], $grupo, "IM") == 0) { audit_db ($config["id_user"],$REMOTE_ADDR,"ACL Forbidden","User tried to read incidents from group without access"); no_permission (); } } $prioridad = (int) get_parameter ("prioridad", -1); if ($prioridad != -1) //-1 = All $filter .= sprintf (" AND prioridad = %d", $prioridad); $offset = (int) get_parameter ("offset", 0); $groups = get_user_groups ($config["id_user"]); //Select incidencts where the user has access to ($groups from //get_user_groups), array_keys for the id, implode to pass to SQL $sql = "SELECT * FROM tincidencia WHERE id_grupo IN (".implode (",",array_keys ($groups)).")".$filter." ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"]; $result = get_db_all_rows_sql ($sql); if (empty ($result)) { $result = array (); $count = 0; } else { $count = count ($result); } echo '

'.__('Incident management').' > '.__('Manage incidents').'

'.__('Filter').'

'; $fields = array(); //Reset empty array $fields[-1] = __('All incidents'); $fields[0] = __('Active incidents'); $fields[2] = __('Rejected incidents'); $fields[3] = __('Expired incidents'); $fields[13] = __('Closed incidents'); print_select ($fields, "estado", $estado, 'javascript:this.form.submit();', '', '', false, false, false, 'w155'); //Legend echo '

'.__('Status').'

- '.__('Active incidents').'
- '.__('Active incidents, with comments').'
- '.__('Rejected incidents').'
- '.__('Closed incidents').'
- '.__('Expired incidents').'

'.__('Priority').'

- '.__('Very Serious').'
- '.__('Serious').'
- '.__('Medium').'
- '.__('Low').'
- '.__('Informative').'
- '.__('Maintenance').'
'; $fields = array(); //Reset empty array $fields[-1] = __('All priorities'); $fields[0] = __('Informative'); $fields[1] = __('Low'); $fields[2] = __('Medium'); $fields[3] = __('Serious'); $fields[4] = __('Very Serious'); $fields[10] = __('Maintenance'); print_select ($fields, "prioridad", $prioridad, 'javascript:this.form.submit();', '','',false,false,false,'w155'); echo '
'; print_select ($groups, "grupo", $grupo, 'javascript:this.form.submit();','','',false,false,false,'w155'); echo ''; // Pass search parameters for possible future filter searching by user print_input_hidden ("usuario", $usuario); print_input_hidden ("texto", $texto); echo "
"; if ($count < 1) { echo '
'.__('No incidents match your search filter').'

'; } else { // TOTAL incidents $url = "index.php?sec=incidencias&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 pagination ($count, $url, $offset); echo '
'; // Show headers $table->width = 750; $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] = __('Delete'); $table->size[0] = 43; $table->size[7] = 50; $table->align[1] = "center"; $table->align[3] = "center"; $table->align[4] = "center"; $table->align[8] = "center"; foreach ($result as $row) { $data = array(); $data[0] = ''.$row["id_incidencia"].''; $attnum = get_db_value ('COUNT(*)', 'tattachment', 'id_incidencia', $row["id_incidencia"]); $notenum = dame_numero_notas ($row["id_incidencia"]); if ($attnum > 0) $data[0] .= '  '; if ($notenum > 0 && $row["estado"] == 0) $row["estado"] = 1; switch ($row["estado"]) { case 0: $data[1] = ''; break; case 1: $data[1] = ''; break; case 2: $data[1] = ''; break; case 3: $data[1] = ''; break; case 13: $data[1] = ''; break; } $data[2] = ''.safe_input (substr ($row["titulo"],0,45)).''; switch ($row["prioridad"]) { case 4: $data[3] = ''; break; case 3: $data[3] = ''; break; case 2: $data[3] = ''; break; case 1: $data[3] = ''; break; case 0: $data[3] = ''; break; case 10: $data[3] = ''; break; } $data[4] = ''; $data[5] = human_time_comparation ($row["actualizacion"]); $data[6] = $row["origen"]; $data[7] = ''.$row["id_usuario"].''; if (give_acl ($config["id_user"], $row["id_grupo"], "IM") || $config["id_user"] == $row["id_usuario"]) { $data[8] = ''; } else { $data[8] = ''; } array_push ($table->data, $data); } print_table ($table); unset ($table); } if (give_acl ($config["id_user"], 0, "IW")) { echo '
'; print_submit_button (__('Create incident'), 'crt', false, 'class="sub next"'); echo '
'; } ?>