Skip to content

Commit

Permalink
listo despido de oips
Browse files Browse the repository at this point in the history
  • Loading branch information
jmatute committed Dec 7, 2011
1 parent 6dc0422 commit 5f45883
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 3 deletions.
1 change: 1 addition & 0 deletions SIELHO/app/controllers/mensajes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def nuevo
@solicitud = Solicitud.find(params[:solicitud_id])
@destinos = [ [ User.find(@solicitud.responsable).username , @solicitud.responsable] ]
@solicitudes = [ [@solicitud.numero,@solicitud.expediente_id]]
@asignacion = Asignacion.where(:enlace_id=>current_user.id,:expediente_id=>@solicitud.expediente_id,:completada=>false)[0]
render :action => "new"
end

Expand Down
12 changes: 11 additions & 1 deletion SIELHO/app/controllers/solicitud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def clasificar
expediente.crear(solicitud.id,current_user.id)
solicitud.expediente_id = expediente.id
solicitud.save
@s = solicitud
AplicationMailer.recibo(solicitante.email).deliver
temp = Mensaje.find(params[:mensaje_id])
temp.expediente_id = expediente.id
Expand All @@ -89,7 +90,6 @@ def clasificar

def pendiente
@solicitudes = Solicitud.all

if current_user.rol.nombre.eql? "enlace"
@asignacion = Asignacion.where(:enlace_id => current_user.id )
end
Expand Down Expand Up @@ -198,4 +198,14 @@ def reclasificar


end

def reasignar
s = Solicitud.find(params[:solicitud_id])
s.update_attributes(:responsable=>params[:nuevo])
@solicitudes = Solicitud.all
if current_user.rol.nombre.eql? "enlace"
@asignacion = Asignacion.where(:enlace_id => current_user.id )
end
render :action=>"pendiente"
end
end
7 changes: 7 additions & 0 deletions SIELHO/app/controllers/usuario_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def activar_oip
user = User.find(Oip.find(params[:id]).usuario_id)
user.activo = !user.activo
user.save

unless user.activo
responsabilidad = Solicitud.where(:finalizada => false,:responsable=>user.id)
responsabilidad.each do |r|
r.update_attributes(:responsable=>current_user.id)
end
end
redirect_to directorio_path
end

Expand Down
11 changes: 11 additions & 0 deletions SIELHO/app/models/solicitud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def crear(doc,fechaM,solicitante,usuario)
self.save
end


def self.posibles(institucion)
a = Oip.where(:institucion_id=>institucion)
x = []
a.each do |o|
if User.find(o.usuario_id).activo
x << ["#{o.pnombre} #{o.papellido}",o.usuario_id]
end
end
return x
end
def self.solicitudes(usuario)

x = User.find(usuario)
Expand Down
6 changes: 6 additions & 0 deletions SIELHO/app/views/mensajes/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<%=semantic_form_for @mensaje , :html => {:multipart => true} do |f|%>
<%if current_user.rol.nombre.eql? "enlace"%>
<h2>Respuesta a asignacion <%=@solicitud.numero%></h2>
<p><%=@asignacion.descripcion%></p></br></br>
<%end%>

<%= f.inputs do%>
<%= f.input :titulo %>

<%= f.input :expediente_id,:as => :select,:label=> "Relativo a solicitud",:collection => @solicitudes %>
<%= f.input :destinatario_id, :as => :select,:label => "Destinatario:", :collection => @destinos %>
<%= f.file_field :document, :label =>"Adjuntar Archivo:" %>
Expand Down
2 changes: 2 additions & 0 deletions SIELHO/app/views/solicitud/clasificar.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%unless @s.nil?%>
<%=semantic_form_for @justificacion do |f|%>

<label>Clasificacion : </label>
Expand All @@ -19,3 +20,4 @@
<%=f.buttons%>
<%end%>
<%end%>
32 changes: 32 additions & 0 deletions SIELHO/app/views/solicitud/pendiente.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,37 @@
<% end%>
</table>
<%elsif current_user.rol.nombre.eql? "admin" %>
<table class="sortable" id="sortabletable" >
<tr>
<th>Numero de solicitud</th> <th> Fecha </th> <th> Responsable </th> <th> Estado </th> <th>Oip </th><th>Reasignar </th>
</tr>
<% @solicitudes.each do |m| %>

<%if m.responsable.eql? current_user.id%>
<tr>
<%= form_tag("/solicitud/#{m.id}/reasignar", :method => "post") do %>
<td><%= link_to m.numero,ver_expediente_path(m,Expediente.find( m.expediente_id)) %> </td>
<td><%="#{m.fecha}"%> </td>
<td><%="#{User.find(Expediente.find(m.expediente_id).creador ).username }"%>
<td>
<%=Estado.find(Expediente.find(m.expediente_id).estado_id).nombre %>
</td>
<td>
<select name="nuevo">
<%Solicitud.posibles(m.institucion_id).each do |x|%>
<option value=<%=x[1]%>> <%=x[0]%> </option>
<%end%>
</select>
</td>
<td><%= submit_tag("Asignar") %>

</td>
<%end%>
</tr>
<%end%>
<% end%>
</table>
<%end%>
5 changes: 4 additions & 1 deletion SIELHO/app/views/solicitud/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<p><strong>Institucion : </strong> <%=Institucion.find( @solicitud.institucion_id).nombre %> </p>
<p><strong>Fecha de solicitud : </strong> <%=@solicitud.fecha%> </p>
<p><strong>Clasificacion : </strong> <%=Clasificacion.find(@solicitud.clasificacion_id).nombre%></p>
<p><strong>Oip Responsable :</strong> <%=Oip.find_by_usuario_id(@expediente.creador).nombre%></p>
<p><strong>Oip Creador :</strong> <%=Oip.find_by_usuario_id(@expediente.creador).nombre%></p>
<p><strong>Usuario Responsable :</strong> <%=User.find(@solicitud.responsable).username%></p>
<p><strong>Estado : </strong> <%=Estado.find(@expediente.estado_id).nombre%></p>
<p><strong>Descripcion: </strong> <%=@solicitud.descripcion%></p>
Expand Down
3 changes: 2 additions & 1 deletion SIELHO/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
match 'plazo/create' => "usuario#createPlazo" ,:as => :create_plazo

match 'solicitud/:solicitud_id/expediente/:expediente_id/reclasificar' => "solicitud#reclasificar", :as=> :reclasificar


match 'solicitud/:solicitud_id/reasignar' => "solicitud#reasignar",:as => :reasignar
# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down

0 comments on commit 5f45883

Please sign in to comment.