diff --git a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java index e528bf7c..f3d42d2e 100644 --- a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java +++ b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadores.java @@ -54,7 +54,9 @@ public class doGetListaTrabalhadores extends siprpServlet{ dbQuery = new StringBuffer(); dbQuery.append("/"+super.servletName+"/?"+empresaId+"/"+estabelecimentoId+"/"+temp); // contruir url links.add(dbQuery.toString()); - desc.add((String)rs.get(index,1)); + HashMap trabalhador = new HashMap(); + trabalhador.put( "Nome", (String)rs.get(index,1) ); + desc.add( trabalhador ); ++index; } stmt.close(); @@ -63,20 +65,20 @@ public class doGetListaTrabalhadores extends siprpServlet{ 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, super.queryStringTrabalhadores ); -hmValues.put( templateVector1,links); -hmValues.put( templateVector2,desc); -hmValues.put( templateVector3,null); -out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate)); + 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, super.queryStringTrabalhadores ); + 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 diff --git a/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresTudo.java b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresTudo.java new file mode 100644 index 00000000..9b365c69 --- /dev/null +++ b/trunk/WEB-INF/classes/siprp/pagina/doGetListaTrabalhadoresTudo.java @@ -0,0 +1,129 @@ +/* + * doGetListaTrabalhadoresTudo.java + * + * Created on 21 de Abril de 2005, 17:35 + */ + +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 doGetListaTrabalhadoresTudo + extends siprpServlet +{ + + /** Creates a new instance of doGetListaTrabalhadores */ + public doGetListaTrabalhadoresTudo(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, data_ficha FROM trabalhadores " + + "WHERE estabelecimento_id = '"+estabelecimentoId+"'" + + " AND ultima_consulta IS NOT NULL AND realizada = 'y' AND" + + " ( proxima_consulta IS NULL OR current_date - proxima_consulta > 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) ); + Object data_ficha = rs.get(index,2); + if( data_ficha == null ) + { + data_ficha = ""; + } + trabalhador.put( "Data", data_ficha ); + 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_tudo" ); + 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 16ee56bf..01335cd0 100644 --- a/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java +++ b/trunk/WEB-INF/classes/siprp/pagina/siprpServlet.java @@ -148,7 +148,7 @@ System.out.println( "query: " + queryString ); } else if ( queryString.indexOf(queryStringErro) == 0 ) // Listar Empresas { - System.out.println( "entrou" ); +// System.out.println( "entrou" ); doErro(queryString, out); } else // interpretar query string diff --git a/trunk/html/user.html b/trunk/html/user.html index 029e13c7..e7069222 100644 --- a/trunk/html/user.html +++ b/trunk/html/user.html @@ -20,6 +20,16 @@ body text-align: justify; } +.bold +{ + color: #497895; + font-family: verdana; + font-size: 10pt; + font-weight: bold; + text-decoration: none; + cursor: pointer; +} + td { font-size: 10pt; @@ -152,8 +162,8 @@ td.box6 links   -   - $userName   logout »    +    $userName  +    logout »    @@ -197,7 +207,7 @@ td.box6 #if( $query == "trabalhador" ) - Funcionário: $!funcionario.nome Nº: $!funcionario.numero + Funcionário: $!funcionario.nome  Data de Nascimento: $!funcionario.data_nascimento #else Funcionário: #end @@ -250,6 +260,12 @@ td.box6 Marcar + #elseif( $query == "trabalhadores" ) + #foreach( $element in $v1 ) + #set ( $counter = $velocityCount - 1 ) + #set ( $dados_trabalhador = $v2.get($counter) ) + $dados_trabalhador.Nome
+ #end #else #foreach( $element in $v1 ) #set ( $counter = $velocityCount - 1 )