diff --git a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java
index f3d42d2e..d0a18b74 100644
--- a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java
+++ b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java
@@ -14,8 +14,20 @@ import org.apache.velocity.app.*;
public class doGetListaTrabalhadores extends siprpServlet{
/** Creates a new instance of doGetListaTrabalhadores */
- public doGetListaTrabalhadores(HttpServletRequest req, HttpServletResponse res) throws IOException
+ public doGetListaTrabalhadores(HttpServletRequest req, HttpServletResponse res, String query) throws IOException
{
+ if( query != null )
+ {
+ if( query.equals( "trabalhadores_tudo" ) )
+ {
+ new doGetListaTrabalhadoresTudo( req, res );
+ }
+ else if( query.equals( "trabalhadores_pendentes" ) )
+ {
+ new doGetListaTrabalhadoresPendentes( req, res );
+ }
+ return;
+ }
ServletOutputStream out = res.getOutputStream();
Connection con = null ;
Statement stmt = null ;
diff --git a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresPendentes.java b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresPendentes.java
new file mode 100644
index 00000000..fdb500e6
--- /dev/null
+++ b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresPendentes.java
@@ -0,0 +1,167 @@
+/*
+ * doGetListaTrabalhadoresPendentes.java
+ *
+ * Created on 22 de Abril de 2005, 15:56
+ */
+
+package siprp.pagina;
+
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.strings.*;
+import java.io.*;
+import java.util.*;
+import java.sql.*;
+import java.lang.reflect.Array;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.velocity.*;
+import org.apache.velocity.app.*;
+/**
+ *
+ * @author fpalma
+ */
+public class doGetListaTrabalhadoresPendentes
+ extends siprpServlet
+{
+
+ /** Creates a new instance of doGetListaTrabalhadores */
+ public doGetListaTrabalhadoresPendentes(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ ServletOutputStream out = res.getOutputStream();
+ Connection con = null ;
+ Statement stmt = null ;
+ ResultSet2DArray rs;
+ StringBuffer dbQuery, sBuffer;
+ String userRole, empresaId, estabelecimentoId, temp;
+ HttpSession session = req.getSession(false);
+ Vector links = new Vector();
+ Vector desc = new Vector();
+ Vector descAdicional = new Vector();
+ try
+ {
+ userRole = (String)session.getAttribute(super.sessionUserRole);
+ empresaId = (String)session.getAttribute(super.sessionEmpresaId);
+ estabelecimentoId = (String)session.getAttribute(super.sessionEstabelecimentoId);
+
+ if ( userRole.equals ( super.superUserRole ) || userRole.equals ( empresaId ) )
+ {
+ Class.forName(super.bdDriver);
+ con = DriverManager.getConnection( super.bdUrl, super.bdUsername, super.bdPassword );
+ if ( super.verificaEstabelecimento(con, empresaId, estabelecimentoId) ) // estabelecimento pertence à empresa ??
+ {
+ //Class.forName(super.bdDriver);
+ //con = DriverManager.getConnection( super.bdUrl, super.bdUsername, super.bdPassword );
+ dbQuery = new StringBuffer();
+ dbQuery.append( "SELECT id, nome, ( ultima_consulta IS NOT NULL AND realizada = 'y' ),"
+ + " ( ultimo_exame IS NOT NULL AND realizado = 'y' ),"
+ + " proxima_consulta IS NOT NULL, proximo_exame IS NOT NULL, "
+ + " ( proxima_consulta IS NOT NULL AND current_date - proxima_consulta <= 14 ), "
+ + " ( proximo_exame IS NOT NULL AND current_date - proximo_exame <= 14 )"
+ + " FROM trabalhadores "
+ + " WHERE estabelecimento_id = '"+estabelecimentoId+"'"
+ + " AND ( ultima_consulta IS NULL OR realizada = 'n' OR"
+ + " ( proxima_consulta IS NOT NULL AND current_date - proxima_consulta <= 14 )"
+ + " OR ( proximo_exame IS NOT NULL AND ( realizado = 'n' OR current_date - proximo_exame <= 14 ) ) )"
+ + " ORDER BY nome" );
+ stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ rs = new ResultSet2DArray( stmt.executeQuery( dbQuery.toString()) );
+
+ int index=0;
+ int max = rs.columnLength();
+
+ while ( index < max )
+ {
+ temp=""+rs.get(index,0); // converter de int para String
+ dbQuery = new StringBuffer();
+ dbQuery.append("/"+super.servletName+"/?"+empresaId+"/"+estabelecimentoId+"/"+temp); // contruir url
+ links.add(dbQuery.toString());
+ HashMap trabalhador = new HashMap();
+ trabalhador.put( "Nome", (String)rs.get(index,1) );
+ boolean uc = ( (Boolean)rs.get(index,2) ).booleanValue();
+ boolean ue = ( (Boolean)rs.get(index,3) ).booleanValue();
+ boolean pc = ( (Boolean)rs.get(index,4) ).booleanValue();
+ boolean pe = ( (Boolean)rs.get(index,5) ).booleanValue();
+ boolean quase_c = ( (Boolean)rs.get(index,6) ).booleanValue();
+ boolean quase_e = ( (Boolean)rs.get(index,7) ).booleanValue();
+ if( quase_c )
+ {
+ trabalhador.put( "Consulta", "yellow" );
+ }
+ else if( uc )
+ {
+ trabalhador.put( "Consulta", "green" );
+ }
+ else if( pc )
+ {
+ trabalhador.put( "Consulta", "yellow" );
+ }
+ else
+ {
+ trabalhador.put( "Consulta", "red" );
+ }
+
+ if( quase_e )
+ {
+ trabalhador.put( "Exame", "yellow" );
+ }
+ else if( ue )
+ {
+ trabalhador.put( "Exame", "green" );
+ }
+ else if( pe )
+ {
+ trabalhador.put( "Exame", "yellow" );
+ }
+ else
+ {
+ trabalhador.put( "Exame", "red" );
+ }
+ desc.add( trabalhador );
+ ++index;
+ }
+ stmt.close();
+
+ sBuffer = new StringBuffer();
+ sBuffer.append(""+super.nomeEmpresa(con,empresaId)+"
"
+ +super.nomeEstabelecimento(con, estabelecimentoId)+"" );
+
+ HashMap hmValues = new HashMap();
+ hmValues.put( "empresa_nome", session.getAttribute( sessionCompanyName ) );
+ hmValues.put( "empresa_id", session.getAttribute( sessionEmpresaId ) );
+ hmValues.put( "estabelecimento_nome", super.nomeEstabelecimento( con, estabelecimentoId ) );
+ hmValues.put( "estabelecimento_id", estabelecimentoId );
+ hmValues.put( "userRole", userRole );
+ hmValues.put( "userName", session.getAttribute( sessionUser ) );
+ hmValues.put( msgTemplate , sBuffer.toString() ) ;
+ hmValues.put( templateUserRole, userRole);
+ hmValues.put( templateQuery, "trabalhadores_pendentes" );
+ hmValues.put( templateVector1,links);
+ hmValues.put( templateVector2,desc);
+ hmValues.put( templateVector3,null);
+ out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate));
+// out.println( mergeTemplate( sBuffer.toString(), userRole, super.queryStringTrabalhadores, links, desc, null, super.authenticatedUserTemplate) );
+ }
+ else // est não pertence à empresa
+ {
+ out.println( mergeTemplate( super.msgLinkFormatError , userRole, super.errorTemplate) );
+ }
+ con.close();
+ }
+ else // Role não permite ver esta informação
+ {
+ out.println( mergeTemplate( super.msgAcessoNegado , userRole, super.errorTemplate) );
+ }
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ out.println( mergeTemplate( super.msgErroBd , super.errorTemplate) );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ out.println( mergeTemplate( super.msgGenericError , super.errorTemplate) );
+ }
+ }
+
+}
diff --git a/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java b/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java
index 01335cd0..07d20f6f 100644
--- a/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java
+++ b/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java
@@ -154,6 +154,7 @@ System.out.println( "query: " + queryString );
else // interpretar query string
{
String empresa = null, estabelecimento=null, trabalhador=null;
+ String query = null;
int checkInt;
StringTokenizer sToken = new StringTokenizer(queryString,"/") ;
@@ -167,7 +168,18 @@ System.out.println( "query: " + queryString );
if (sToken.hasMoreElements())
{
trabalhador = sToken.nextToken(); // trabalhador ID
- checkInt = Integer.parseInt(trabalhador); // check int, NumberFormatException
+ try
+ {
+ checkInt = Integer.parseInt(trabalhador); // check int, NumberFormatException
+ }
+ catch( NumberFormatException nfex )
+ {
+ query = trabalhador;
+ if( !query.equals( "trabalhadores_tudo" ) && !query.equals( "trabalhadores_pendentes" ) )
+ {
+ throw nfex;
+ }
+ }
}
}
@@ -179,12 +191,12 @@ System.out.println( "query: " + queryString );
//out.println( mergeTemplate ( empresa, loginTemplate ) ) ;
}
- else if ( trabalhador == null ) // estabelecimento query
+ else if ( trabalhador == null || query != null ) // estabelecimento query
{
session.setAttribute(sessionEmpresaId, empresa); // update HTTP Session
session.setAttribute(sessionEstabelecimentoId, estabelecimento);
- new doGetListaTrabalhadores(req,res);
+ new doGetListaTrabalhadores(req,res, query);
//out.println( mergeTemplate ( " chama oGetListaTrabalhadores", loginTemplate ) ) ;
}