diff --git a/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java index 90b93ac3..3713fa99 100644 --- a/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java +++ b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java @@ -12,6 +12,8 @@ import com.evolute.utils.sql.Select2; import db.data.siprp.outer.UtilizadoresData; import db.entidades.Utilizador; import global.Global; +import java.sql.ResultSet; +import java.sql.Statement; import java.util.LinkedList; import java.util.List; @@ -134,72 +136,72 @@ public class UtilizadoresDataProvider extends GenericDataProvider throws Exception { List< Utilizador > list = new LinkedList< Utilizador >(); - - int type = tipo.intValue(); - - Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ).and( - new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) ); - - if ( type == Global.DIRECTOR_LOJA || tipo == Global.RESPONSAVEL_SEGURANCA || tipo == Global.DIRECTOR_NACIONAL_SEGURANCA ) - { - where = where.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ); - } - if ( tipo == Global.RESPONSAVEL_SEGURANCA && "y".equals( responsavel_loja ) ) - { - where = where.and( new Field( UtilizadoresData.RESPONSAVEL_LOJA_FULL ).isEqual( "y" ) ); - } - - System.out.println( "UtilizadoresDataProvider . getUtilizadoresListByTipo() : " + where.toString() ); - - List< UtilizadoresData > listData = getProvider().listLoad( UtilizadoresData.class, where, new String[] { UtilizadoresData.NOME }, null ); - for ( UtilizadoresData userData : listData ) - { - list.add( copyFrom( userData ) ); - } - -// Statement st = createStatement(); -// String sql = ""; -// String estabelecimento_constraint = ""; -// if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.RESPONSAVEL_SEGURANCA || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) -// { -// estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id; -// } -// if(tipo.intValue() == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches("y")) -// { -// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND responsavel_loja = 'y' AND tipo = " + tipo + estabelecimento_constraint; -// } -// else if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.TECNICO_HS || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) -// { -// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint; -// } // -// System.out.println("UTILIZADORES LIST BY TIPO SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// Utilizador u = new Utilizador(); -// u.setId(new Integer(rs.getInt("id"))); -// u.setLogin(rs.getString("login")); -// u.setPassword(rs.getString("password")); -// u.setData_password(rs.getDate("data_password")); -// u.setEmail(rs.getString("email")); -// u.setEmpresa_id(new Integer(rs.getInt("empresa_id"))); -// u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id"))); -// u.setAdministrador(rs.getString("administrador")); -// u.setTipo(new Integer(rs.getInt("tipo"))); -// u.setNumero_cedula(rs.getString("numero_cedula")); -// u.setCap(rs.getString("cap")); -// u.setNome(rs.getString("nome")); -// u.setMedico_id(new Integer(rs.getInt("medico_id"))); -// u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id"))); -// u.setActivo(rs.getString("activo")); -// u.setResponsavel_loja(rs.getString("responsavel_loja")); -// list.add(u); -// }while(rs.next()); -// } +// int type = tipo.intValue(); +// +// Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ).and( +// new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) ); +// +// if ( type == Global.DIRECTOR_LOJA || tipo == Global.RESPONSAVEL_SEGURANCA || tipo == Global.DIRECTOR_NACIONAL_SEGURANCA ) +// { +// where = where.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ); +// } +// if ( tipo == Global.RESPONSAVEL_SEGURANCA && "y".equals( responsavel_loja ) ) +// { +// where = where.and( new Field( UtilizadoresData.RESPONSAVEL_LOJA_FULL ).isEqual( "y" ) ); +// } +// +// System.out.println( "UtilizadoresDataProvider . getUtilizadoresListByTipo() : " + where.toString() ); +// +// List< UtilizadoresData > listData = getProvider().listLoad( UtilizadoresData.class, where, new String[] { UtilizadoresData.NOME }, null ); +// for ( UtilizadoresData userData : listData ) +// { +// list.add( copyFrom( userData ) ); +// } + + Statement st = createStatement(); + String sql = ""; + String estabelecimento_constraint = ""; + if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.RESPONSAVEL_SEGURANCA || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) + { + estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id; + } + if(tipo.intValue() == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches("y")) + { + sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND responsavel_loja = 'y' AND tipo = " + tipo + estabelecimento_constraint; + } + else if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.TECNICO_HS || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) + { + sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint; + } + + System.out.println("UTILIZADORES LIST BY TIPO SQL : " + sql); + ResultSet rs = st.executeQuery(sql); + if(rs.isBeforeFirst()) + { + rs.first(); + do + { + Utilizador u = new Utilizador(); + u.setId(new Integer(rs.getInt("id"))); + u.setLogin(rs.getString("login")); + u.setPassword(rs.getString("password")); + u.setData_password(rs.getDate("data_password")); + u.setEmail(rs.getString("email")); + u.setEmpresa_id(new Integer(rs.getInt("empresa_id"))); + u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id"))); + u.setAdministrador(rs.getString("administrador")); + u.setTipo(new Integer(rs.getInt("tipo"))); + u.setNumero_cedula(rs.getString("numero_cedula")); + u.setCap(rs.getString("cap")); + u.setNome(rs.getString("nome")); + u.setMedico_id(new Integer(rs.getInt("medico_id"))); + u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id"))); + u.setActivo(rs.getString("activo")); + u.setResponsavel_loja(rs.getString("responsavel_loja")); + list.add(u); + }while(rs.next()); + } return list; } diff --git a/trunk/PlanosActuacao/src/java/mail/Mail.java b/trunk/PlanosActuacao/src/java/mail/Mail.java index cb938234..81986013 100644 --- a/trunk/PlanosActuacao/src/java/mail/Mail.java +++ b/trunk/PlanosActuacao/src/java/mail/Mail.java @@ -79,7 +79,7 @@ public class Mail { t.sendMessage( msg, msg.getAllRecipients() ); t.close(); - System.out.println("Email Enviado !!!! "); +// System.out.println("Email Enviado !!!! "); }