diff --git a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java index 39d1628c..d9f7e9a6 100644 --- a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java +++ b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java @@ -5,6 +5,7 @@ package db.providers; +import com.evolute.utils.strings.StringPlainer; import db.entidades.Area; import db.entidades.EstadoMedida; import db.entidades.Medida; @@ -423,119 +424,285 @@ public class PlanosDataProvider extends GenericDataProvider{ // } // return list; // } - - public ArrayList getPlanosActivos(Utilizador u) throws Exception - { - int userType = u.getTipo().intValue(); - Statement st = createStatement(); - String sql = "select * from planos_actuacao "; - - switch(userType) + + + public String getExpression( String nome, String estabelecimento, String dataVisita ) + { + String tables = "planos_actuacao"; + String whereExpression = "planos_actuacao.deleted_date IS NULL "; + + if ( nome != null ) + { + nome = StringPlainer.convertString( nome.trim() ); + nome = nome.replaceAll( " ", "%" ); + whereExpression += "AND plain_utf8( planos_actuacao.tecnico_hs_nome ) LIKE '%" + nome + "%' "; + } + if ( estabelecimento != null ) + { + estabelecimento = StringPlainer.convertString( estabelecimento.trim() ); + estabelecimento = estabelecimento.replaceAll( " ", "%" ); + whereExpression += "AND plain_utf8( planos_actuacao.nome_estabelecimento ) LIKE '%" + estabelecimento + "%' "; + } + if ( dataVisita != null ) + { + whereExpression += "AND planos_actuacao.data_visita = '" + dataVisita + "' "; + } + + return "SELECT * FROM " + tables + " WHERE " + whereExpression; + } + + + + private String getFaseActivos( Utilizador u ) + { + String sql = ""; + int userType = u.getTipo().intValue(); + switch ( userType ) { case Global.TECNICO_HS: - sql += "WHERE fase = 1 OR fase = 5"; + sql += "(fase = 1 OR fase = 5)"; break; - + case Global.RESPONSAVEL_SEGURANCA: - sql += "WHERE fase = 2"; + sql += "fase = 2"; break; - + case Global.DIRECTOR_LOJA: - sql += "WHERE fase = 3"; + sql += "fase = 3"; break; - + case Global.DIRECTOR_NACIONAL_SEGURANCA: - sql += "WHERE fase = 4"; + sql += "fase = 4"; break; } - if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA) + if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA ) { - sql += " and estabelecimento_id = " + u.getEstabelecimento_id(); + sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); } - sql += " and deleted_date is null"; - - ResultSet rs = st.executeQuery(sql); - ArrayList list = getFullPlanos(rs); - return list; - } - - public ArrayList getPlanosSeguimento(Utilizador u) throws Exception - { - Statement st = createStatement(); - int userType = u.getTipo().intValue(); - - String sql = "select * from planos_actuacao "; - - switch(userType) + return sql; + } + + + public List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + throws Exception + { + Statement st = createStatement(); + String sql = getExpression( nome, estabelecimento, dataVisita ); + sql += " AND " + getFaseActivos( u ); + + System.out.println( "SEARCH ACTIVOS" ); + System.out.println( "SQL: " + sql ); + + ResultSet rs = st.executeQuery(sql); + List< PlanoActuacao > list = getFullPlanos( rs ); + return list; + } + +// public ArrayList getPlanosActivos(Utilizador u) throws Exception +// { +// Statement st = createStatement(); +// int userType = u.getTipo().intValue(); +// Statement st = createStatement(); +// String sql = "select * from planos_actuacao WHERE "; +// +// switch(userType) +// { +// case Global.TECNICO_HS: +// sql += "fase = 1 OR fase = 5"; +// break; +// +// case Global.RESPONSAVEL_SEGURANCA: +// sql += "fase = 2"; +// break; +// +// case Global.DIRECTOR_LOJA: +// sql += "fase = 3"; +// break; +// +// case Global.DIRECTOR_NACIONAL_SEGURANCA: +// sql += "fase = 4"; +// break; +// } +// if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA ) +// { +// sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); +// } +// sql += " AND deleted_date IS NULL"; +// +// ResultSet rs = st.executeQuery(sql); +// ArrayList list = getFullPlanos(rs); +// +// return list; +// } + + + + private String getFaseSeguimento( Utilizador u ) + { + int userType = u.getTipo(); + String sql = ""; + switch( userType ) { case Global.TECNICO_HS: - sql += "WHERE fase <> 1 AND fase <> 5 AND fase <> 6"; - break; - + sql = "(fase <> 1 AND fase <> 5 AND fase <> 6)"; + break; case Global.RESPONSAVEL_SEGURANCA: - sql += "WHERE fase <> 2 AND fase <> 6"; - break; - + sql = "(fase <> 2 AND fase <> 6)"; + break; case Global.DIRECTOR_LOJA: - sql += "WHERE fase <> 3 AND fase <> 6"; - break; - + sql = "(fase <> 3 AND fase <> 6)"; + break; case Global.DIRECTOR_NACIONAL_SEGURANCA: - sql += "WHERE fase <> 4 AND fase <> 6"; - break; - + sql = "(fase <> 4 AND fase <> 6)"; + break; case Global.DIRECTOR_SIPRP: - sql += "WHERE fase > 1 AND fase < 6"; - break; - case Global.RH: - sql += "WHERE fase > 1 AND fase < 6"; - break; - case Global.DIRECTOR_GERAL_RH: - sql += "WHERE fase > 1 AND fase < 6"; - break; - case Global.GESTOR: - sql += "WHERE fase > 1 AND fase < 6"; - break; - } - if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH && userType != Global.GESTOR) - { - sql += " and estabelecimento_id = " + u.getEstabelecimento_id(); + sql = "(fase > 1 AND fase < 6)"; + break; + default: + break; } - //System.out.println("USER ESTABELECIMENTO GESTOR : " + u.getEstabelecimento_gestor().intValue()); - if(userType == Global.GESTOR) + if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS + && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH + && userType != Global.GESTOR ) + { + sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); + } + if ( userType == Global.GESTOR ) { - if(u.getEstabelecimento_gestor().intValue() > 0) + if ( u.getEstabelecimento_gestor().intValue() > 0 ) { - sql += " and estabelecimento_id = " + u.getEstabelecimento_gestor(); + sql += " AND estabelecimento_id = " + u.getEstabelecimento_gestor(); } } - sql += " and deleted_date is null"; - System.out.println("PLANOS SEGUIMENTO SQL : " + sql); - ResultSet rs = st.executeQuery(sql); + return sql; + } + + public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita ) + throws Exception + { + Statement st = createStatement(); + + String sql = getExpression( nome, estabelecimento, dataVisita ); + sql += " AND " + getFaseSeguimento( u ); + + System.out.println( "SEARCH SEGUIMENTO" ); + System.out.println( "SQL: " + sql ); + + ResultSet rs = st.executeQuery(sql); ArrayList list = getFullPlanos(rs); - return list; - } - - public ArrayList getPlanosConcluidos(Utilizador u) throws Exception - { - int userType = u.getTipo().intValue(); - Statement st = createStatement(); - String sql = "select * from planos_actuacao where fase = 6"; - if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH) + return list; + } + +// public ArrayList getPlanosSeguimento(Utilizador u) throws Exception +// { +// Statement st = createStatement(); +// +// String sql = "select * from planos_actuacao "; +// switch(userType) +// { +// case Global.TECNICO_HS: +// sql += "WHERE fase <> 1 AND fase <> 5 AND fase <> 6"; +// break; +// +// case Global.RESPONSAVEL_SEGURANCA: +// sql += "WHERE fase <> 2 AND fase <> 6"; +// break; +// +// case Global.DIRECTOR_LOJA: +// sql += "WHERE fase <> 3 AND fase <> 6"; +// break; +// +// case Global.DIRECTOR_NACIONAL_SEGURANCA: +// sql += "WHERE fase <> 4 AND fase <> 6"; +// break; +// +// case Global.DIRECTOR_SIPRP: +// sql += "WHERE fase > 1 AND fase < 6"; +// break; +// +// case Global.RH: +// sql += "WHERE fase > 1 AND fase < 6"; +// break; +// +// case Global.DIRECTOR_GERAL_RH: +// sql += "WHERE fase > 1 AND fase < 6"; +// break; +// +// case Global.GESTOR: +// sql += "WHERE fase > 1 AND fase < 6"; +// break; +// } +// if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH && userType != Global.GESTOR) +// { +// sql += " and estabelecimento_id = " + u.getEstabelecimento_id(); +// } +// +// //System.out.println("USER ESTABELECIMENTO GESTOR : " + u.getEstabelecimento_gestor().intValue()); +// if(userType == Global.GESTOR) +// { +// if(u.getEstabelecimento_gestor().intValue() > 0) +// { +// sql += " and estabelecimento_id = " + u.getEstabelecimento_gestor(); +// } +// } +// sql += " and deleted_date is null"; +// +// System.out.println("PLANOS SEGUIMENTO SQL : " + sql); +// ResultSet rs = st.executeQuery(sql); +// ArrayList list = getFullPlanos(rs); +// return list; +// } + + + private String getFaseConcluidos( Utilizador u ) + { + int userType = u.getTipo().intValue(); + String sql = "fase = 6"; + + if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS + && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH ) { - sql += " and estabelecimento_id = " + u.getEstabelecimento_id(); + sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); } - sql += " and deleted_date is null"; - System.out.println("PLANOS CONCLUIDOS SQL : " + sql); - ResultSet rs = st.executeQuery(sql); - ArrayList list = getFullPlanos(rs); - return list; - } + + return sql; + } + + public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + throws Exception + { + String sql = getExpression( nome, estabelecimento, dataVisita ); + sql += " AND " + getFaseConcluidos( u ); + + System.out.println( "SEARCH CONCLUIDOS" ); + System.out.println( "SQL: " + sql ); + + Statement st = createStatement(); + ResultSet rs = st.executeQuery( sql ); + ArrayList< PlanoActuacao > list = getFullPlanos( rs ); + return list; + } + +// public ArrayList getPlanosConcluidos(Utilizador u) throws Exception +// { +// int userType = u.getTipo().intValue(); +// Statement st = createStatement(); +// String sql = "select * from planos_actuacao where fase = 6"; +// if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH) +// { +// sql += " and estabelecimento_id = " + u.getEstabelecimento_id(); +// } +// sql += " and deleted_date is null"; +// System.out.println("PLANOS CONCLUIDOS SQL : " + sql); +// ResultSet rs = st.executeQuery(sql); +// ArrayList list = getFullPlanos(rs); +// return list; +// } private ArrayList getFullPlanos(ResultSet rs) throws Exception { diff --git a/trunk/PlanosActuacao/src/java/mail/Mail.java b/trunk/PlanosActuacao/src/java/mail/Mail.java index d9cd68bf..c043ab9f 100644 --- a/trunk/PlanosActuacao/src/java/mail/Mail.java +++ b/trunk/PlanosActuacao/src/java/mail/Mail.java @@ -24,30 +24,39 @@ import javax.mail.internet.MimeMultipart; * @author lluis */ public class Mail { - -private final static String SERVIDOR_SMTP = "mail2.evolute.pt"; -private final static String SERVIDOR_SMTP_PASSWORD = "EVOLUTE"; -public final static String ENDERECO_ENVIO = "planos.auchan@siprp.pt"; -//public final static String ENDERECO_ENVIO = "lluis@evolute.pt"; //testes + + + private final static String SMTP_HOST = "mail2.evolute.pt"; + private final static int SMTP_PORT = 587; + + private final String mail_username = "acidentes.auchan@siprp.pt"; + private final String mail_password = "47Ju6Vb"; + + public final static String ENDERECO_ENVIO = "planos.auchan@siprp.pt"; + //public final static String ENDERECO_ENVIO = "lluis@evolute.pt"; //testes public void send(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception { Properties props = new Properties(); //props.put("mail.transport.protocol", "smtp"); - props.put("mail.smtp.host", SERVIDOR_SMTP); - props.put("mail.from", emailFrom); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.user", "lluis"); - props.put("mail.smtp.password", "654321"); - // Session session1 = Session.getInstance(props); - Authenticator auth = new SMTPAuthenticator(); - Session session = Session.getDefaultInstance(props, auth); - - Message msg = new MimeMessage(session); - msg.setFrom(new InternetAddress(emailFrom)); - InternetAddress[] address = {new InternetAddress(emailTo)}; - msg.setRecipients(Message.RecipientType.TO, address); + props.put("mail.smtp.host", SMTP_HOST ); + props.put("mail.from", emailFrom ); + props.put("mail.smtp.auth", "true" ); + props.put("mail.smtp.user", mail_username ); + props.put("mail.smtp.password", mail_password ); +// props.put("mail.smtp.user", "lluis"); +// props.put("mail.smtp.password", "654321"); + + + Session session = Session.getInstance( props ); +// Authenticator auth = new SMTPAuthenticator(); +// Session session = Session.getDefaultInstance(props, auth); + + Message msg = new MimeMessage( session ); + msg.setFrom( new InternetAddress( emailFrom ) ); + InternetAddress[] address = {new InternetAddress( emailTo )}; + msg.setRecipients( Message.RecipientType.TO, address ); ((MimeMessage)msg).setSubject(assunto, "UTF-8"); msg.setSentDate(new Date()); Multipart multipart = new MimeMultipart(); @@ -59,19 +68,27 @@ public final static String ENDERECO_ENVIO = "planos.auchan@siprp.pt"; html+=""; msgBodyPart.setContent(html, "text/html"); multipart.addBodyPart(msgBodyPart); - msg.setContent(multipart); - Transport.send(msg); + msg.setContent(multipart); + +// Transport.send(msg); + Transport t; + t = session.getTransport( "smtp" ); + + t.connect( SMTP_HOST, SMTP_PORT, mail_username, mail_password ); + t.sendMessage( msg, msg.getAllRecipients() ); + + t.close(); System.out.println("Email Enviado !!!! "); } - private class SMTPAuthenticator extends Authenticator { - public PasswordAuthentication getPasswordAuthentication() { - String username = "lluis"; - String password = "654321"; - return new PasswordAuthentication(username, password); - } - - } +// private class SMTPAuthenticator extends Authenticator { +// public PasswordAuthentication getPasswordAuthentication() { +// String username = "lluis"; +// String password = "654321"; +// return new PasswordAuthentication(username, password); +// } +// +// } } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java index 63a30a0e..903fb0ba 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java @@ -11,15 +11,20 @@ import com.evolute.utils.timer.Timer; import com.sun.data.provider.RowKey; import com.sun.rave.web.ui.appbase.AbstractPageBean; import com.sun.webui.jsf.component.Button; +import com.sun.webui.jsf.component.PanelGroup; +import com.sun.webui.jsf.component.StaticText; import com.sun.webui.jsf.component.Table; import com.sun.webui.jsf.component.TableColumn; import com.sun.webui.jsf.component.TableRowGroup; +import com.sun.webui.jsf.component.TextField; import db.Dblocal; import db.entidades.PlanoActuacao; import db.providers.UtilizadoresDataProvider; import db.entidades.Utilizador; import db.providers.PlanosDataProvider; import global.Global; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -91,8 +96,7 @@ public class ListaPlanos extends AbstractPageBean { this.tableRowGroup3 = trg; } - // - PlanosDataProvider pdp = new PlanosDataProvider(); + private HtmlPanelGrid gridActual = new HtmlPanelGrid(); public HtmlPanelGrid getGridActual() { @@ -148,6 +152,184 @@ public class ListaPlanos extends AbstractPageBean { this.buttonDesactivarSeguimento = b; } + private HtmlPanelGrid gridPanelFilterActual = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterActual() + { + return this.gridPanelFilterActual; + } + public void setGridPanelFilterActual( HtmlPanelGrid pg ) + { + this.gridPanelFilterActual = pg; + } + + private PanelGroup groupPanelFilterActual = new PanelGroup(); + public PanelGroup getGroupPanelFilterActual() + { + return this.groupPanelFilterActual; + } + public void setGroupPanelFilterActual( PanelGroup pg ) + { + this.groupPanelFilterActual = pg; + } + + private TextField textFilterNameActual = new TextField(); + public TextField getTextFilterNameActual() + { + return this.textFilterNameActual; + } + public void setTextFilterNameActual( TextField tf ) + { + this.textFilterNameActual = tf; + } + + private TextField textFilterEstabelecimentoActual = new TextField(); + + public TextField getTextFilterEstabelecimentoActual() { + return textFilterEstabelecimentoActual; + } + public void setTextFilterEstabelecimentoActual(TextField textFilterEstabelecimentoActual) { + this.textFilterEstabelecimentoActual = textFilterEstabelecimentoActual; + } + + private com.sun.webui.jsf.component.Calendar calFilterDateActual = new com.sun.webui.jsf.component.Calendar(); + public com.sun.webui.jsf.component.Calendar getCalFilterDateActual() { + return calFilterDateActual; + } + public void setCalFilterDateActual(com.sun.webui.jsf.component.Calendar calFilterDateActual) { + this.calFilterDateActual = calFilterDateActual; + } + + private Button buttonFilterActual = new Button(); + public Button getButtonFilterActual() + { + return this.buttonFilterActual; + } + public void setButtonFilterActual( Button b ) + { + this.buttonFilterActual = b; + } + + + + private HtmlPanelGrid gridPanelFilterSeg = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterSeg() + { + return this.gridPanelFilterSeg; + } + public void setGridPanelFilterSeg( HtmlPanelGrid pg ) + { + this.gridPanelFilterSeg = pg; + } + + private PanelGroup groupPanelFilterSeg = new PanelGroup(); + public PanelGroup getGroupPanelFilterSeg() + { + return this.groupPanelFilterSeg; + } + public void setGroupPanelFilterSeg( PanelGroup pg ) + { + this.groupPanelFilterSeg = pg; + } + + private TextField textFilterNameSeg = new TextField(); + public TextField getTextFilterNameSeg() + { + return this.textFilterNameSeg; + } + public void setTextFilterNameSeg( TextField tf ) + { + this.textFilterNameSeg = tf; + } + + private TextField textFilterEstabelecimentoSeg = new TextField(); + + public TextField getTextFilterEstabelecimentoSeg() { + return textFilterEstabelecimentoSeg; + } + public void setTextFilterEstabelecimentoSeg(TextField textFilterEstabelecimentoSeg) { + this.textFilterEstabelecimentoSeg = textFilterEstabelecimentoSeg; + } + + private com.sun.webui.jsf.component.Calendar calFilterDateSeg = new com.sun.webui.jsf.component.Calendar(); + public com.sun.webui.jsf.component.Calendar getCalFilterDateSeg() { + return calFilterDateSeg; + } + public void setCalFilterDateSeg(com.sun.webui.jsf.component.Calendar calFilterDateSeg) { + this.calFilterDateSeg = calFilterDateSeg; + } + + private Button buttonFilterSeg = new Button(); + public Button getButtonFilterSeg() + { + return this.buttonFilterSeg; + } + public void setButtonFilterSeg( Button b ) + { + this.buttonFilterSeg = b; + } + + + private HtmlPanelGrid gridPanelFilterConc = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterConc() + { + return this.gridPanelFilterConc; + } + public void setGridPanelFilterConc( HtmlPanelGrid pg ) + { + this.gridPanelFilterConc = pg; + } + + private PanelGroup groupPanelFilterConc = new PanelGroup(); + public PanelGroup getGroupPanelFilterConc() + { + return this.groupPanelFilterConc; + } + public void setGroupPanelFilterConc( PanelGroup pg ) + { + this.groupPanelFilterConc = pg; + } + + private TextField textFilterNameConc = new TextField(); + public TextField getTextFilterNameConc() + { + return this.textFilterNameConc; + } + public void setTextFilterNameConc( TextField tf ) + { + this.textFilterNameConc = tf; + } + + private TextField textFilterEstabelecimentoConc = new TextField(); + + public TextField getTextFilterEstabelecimentoConc() { + return textFilterEstabelecimentoConc; + } + public void setTextFilterEstabelecimentoConc(TextField textFilterEstabelecimentoConc) { + this.textFilterEstabelecimentoConc = textFilterEstabelecimentoConc; + } + + private com.sun.webui.jsf.component.Calendar calFilterDateConc = new com.sun.webui.jsf.component.Calendar(); + public com.sun.webui.jsf.component.Calendar getCalFilterDateConc() { + return calFilterDateConc; + } + public void setCalFilterDateConc(com.sun.webui.jsf.component.Calendar calFilterDateConc) { + this.calFilterDateConc = calFilterDateConc; + } + + private Button buttonFilterConc = new Button(); + public Button getButtonFilterConc() + { + return this.buttonFilterConc; + } + public void setButtonFilterConc( Button b ) + { + this.buttonFilterConc = b; + } + + private static final DateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" ); + // + + PlanosDataProvider pdp = new PlanosDataProvider(); /** *

Construct a new Page bean instance.

@@ -568,16 +750,24 @@ FacesContext context = FacesContext.getCurrentInstance(); // } ////PlanosActuacao planos = new PlanosActuacao(u); - - List listPlanosActivos = getPlanosActivos(u); - getSessionBean1().getPlanosActualDataProvider().setList(listPlanosActivos); - - List listPlanosSeguimento = getPlanosSeguimento(u); - getSessionBean1().getPlanosSeguimentoDataProvider().setList(listPlanosSeguimento); - - List listPlanosConcluidos = getPlanosConcluidos(u); - getSessionBean1().getPlanosConcluidosDataProvider().setList(listPlanosConcluidos); - + + + + System.out.println( "INITIALIZE:" ); + + if ( ! getSessionBean1().getIsSearchingPlanosActuacao() ) + { + System.out.println( "\tGETTING INITIAL VALUES FOR EACH TABLE." ); + + List listPlanosActivos = getPlanosActivos(u); + getSessionBean1().getPlanosActualDataProvider().setList(listPlanosActivos); + + List listPlanosSeguimento = getPlanosSeguimento(u); + getSessionBean1().getPlanosSeguimentoDataProvider().setList(listPlanosSeguimento); + + List listPlanosConcluidos = getPlanosConcluidos(u); + getSessionBean1().getPlanosConcluidosDataProvider().setList(listPlanosConcluidos); + } //checkPlanosDelayed(); } @@ -674,51 +864,216 @@ FacesContext context = FacesContext.getCurrentInstance(); // } // } + public List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + { + List< PlanoActuacao > list = new ArrayList< PlanoActuacao >(); + try + { + if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP + && u.getTipo().intValue() != Global.GESTOR + && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH ) + { + list = pdp.searchPlanosActivos( u, nome, estabelecimento, dataVisita ); + } + } + catch ( Exception e ) + { + e.printStackTrace(); + } + return list; + } + public List getPlanosActivos(Utilizador u) { - ArrayList list = new ArrayList(); + return searchPlanosActivos( u, null, null, null ); +// List< PlanoActuacao > list = new ArrayList(); +// try +// { +// if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP +// && u.getTipo().intValue() != Global.GESTOR +// && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH ) +// { +//// list = pdp.getPlanosActivos(u); +// list = pdp.searchPlanosActivos( u, null, null ); +// } +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } +// return list; + } + + public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita ) + { + List< PlanoActuacao > list = new ArrayList(); try { - if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.GESTOR && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH) - { - list = pdp.getPlanosActivos(u); - } + list = pdp.searchPlanosSeguimento( u, nome, estabelecimento, dataVisita ); } catch(Exception ex) { ex.printStackTrace(); } return list; - } + } public List getPlanosSeguimento(Utilizador u) { - ArrayList list = new ArrayList(); + return searchPlanosSeguimento( u, null, null, null ); +// List< PlanoActuacao > list = new ArrayList(); +// try +// { +//// list = pdp.getPlanosSeguimento(u); +// list = pdp.searchPlanosSeguimento( u, null, null ); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } +// return list; + } + + public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + { + List< PlanoActuacao > list = new ArrayList(); try { - list = pdp.getPlanosSeguimento(u); - + list = pdp.searchPlanosConcluidos( u, nome, estabelecimento, dataVisita ); } catch(Exception ex) { ex.printStackTrace(); } return list; - } + } public List getPlanosConcluidos(Utilizador u) { - ArrayList list = new ArrayList(); - try + return searchPlanosConcluidos( u, null, null, null ); +// List< PlanoActuacao > list = new ArrayList(); +// try +// { +//// list = pdp.getPlanosConcluidos(u); +// list = pdp.searchPlanosConcluidos( u, null, null ); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } +// return list; + } + + + + public String buttonFilterActual_action() + { + String nome = null; + if ( textFilterNameActual.getText() != null ) { - list = pdp.getPlanosConcluidos(u); + nome = (( String ) textFilterNameActual.getText()).trim(); + if( nome.length() == 0 ) + { + nome = null; + } } - catch(Exception ex) + + String estabelecimento = null; + if ( textFilterEstabelecimentoActual.getText() != null ) { - ex.printStackTrace(); + estabelecimento = (( String ) textFilterEstabelecimentoActual.getText()).trim(); + if( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } } - return list; - } - + + Date visitaDate = ( Date ) calFilterDateActual.getValue(); + String visitaDateStr = null; + if ( visitaDate != null ) + { + visitaDateStr = D_F.format( visitaDate ); + } + + getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE ); + getSessionBean1().getPlanosActualDataProvider().setList( + searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) ); + + return null; + } + + public String buttonFilterSeg_action() + { + String nome = null; + if ( textFilterNameSeg.getText() != null ) + { + nome = (( String ) textFilterNameSeg.getText()).trim(); + if( nome.length() == 0 ) + { + nome = null; + } + } + + String estabelecimento = null; + if ( textFilterEstabelecimentoSeg.getText() != null ) + { + estabelecimento = (( String ) textFilterEstabelecimentoSeg.getText()).trim(); + if( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } + } + + Date visitaDate = ( Date ) calFilterDateSeg.getValue(); + String visitaDateStr = null; + if ( visitaDate != null ) + { + visitaDateStr = D_F.format( visitaDate ); + } + + getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE ); + getSessionBean1().getPlanosSeguimentoDataProvider().setList( + searchPlanosSeguimento( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) ); + + return null; + } + + + public String buttonFilterConc_action() + { + String nome = null; + if ( textFilterNameConc.getText() != null ) + { + nome = (( String ) textFilterNameConc.getText()).trim(); + if( nome.length() == 0 ) + { + nome = null; + } + } + + String estabelecimento = null; + if ( textFilterEstabelecimentoConc.getText() != null ) + { + estabelecimento = (( String ) textFilterEstabelecimentoConc.getText()).trim(); + if( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } + } + + Date visitaDate = ( Date ) calFilterDateConc.getValue(); + String visitaDateStr = null; + if ( visitaDate != null ) + { + visitaDateStr = D_F.format( visitaDate ); + } + + getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE ); + getSessionBean1().getPlanosConcluidosDataProvider().setList( + searchPlanosConcluidos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) ); + + return null; + } + } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java b/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java index 30126302..6cf172fb 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java @@ -74,6 +74,9 @@ public class SessionBean1 extends AbstractSessionBean { private String logoEmpresaUrl = ""; + private Boolean isSearchingPlanosActuacao = Boolean.FALSE; + + /** *

Construct a new session data bean instance.

*/ @@ -379,5 +382,13 @@ public class SessionBean1 extends AbstractSessionBean { this.logoEmpresaUrl = logoEmpresaUrl; } + public Boolean getIsSearchingPlanosActuacao() { + return isSearchingPlanosActuacao; + } + + public void setIsSearchingPlanosActuacao(Boolean isSearchingPlanosActuacao) { + this.isSearchingPlanosActuacao = isSearchingPlanosActuacao; + } + } diff --git a/trunk/PlanosActuacao/web/ListaPlanos.jsp b/trunk/PlanosActuacao/web/ListaPlanos.jsp index c3e5651e..6a3bb0f6 100644 --- a/trunk/PlanosActuacao/web/ListaPlanos.jsp +++ b/trunk/PlanosActuacao/web/ListaPlanos.jsp @@ -35,7 +35,9 @@ - + + +
@@ -50,7 +52,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -113,12 +158,34 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -140,6 +207,8 @@ + + @@ -151,7 +220,8 @@ -
+ +