From 8c6e627e8ef2b871f5abce517147cba512fffce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=20Lu=C3=ADs=20=3D?= Date: Wed, 14 Jan 2009 12:40:15 +0000 Subject: [PATCH] 14/01/2009 git-svn-id: https://svn.coded.pt/svn/SIPRP@909 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../nbproject/navigation.NavData | 8 +- .../java/analiseacidentestrabalho/Acesso.java | 94 ++++++++++++++++++- .../AnaliseAcidenteTrabalho.java | 11 ++- .../java/analiseacidentestrabalho/Dummy.java | 9 ++ .../analiseacidentestrabalho/FormGestor.java | 19 +++- .../java/analiseacidentestrabalho/Login.java | 16 +++- .../SessionBean1.java | 25 ++++- .../analiseacidentestrabalho/Utilizador.java | 16 ++++ .../src/java/db/AnalisesDataProvider.java | 56 ++++++++++- .../src/java/db/Dblocal.java | 2 +- .../src/java/global/Global.java | 10 +- trunk/AnaliseAcidentesTrabalho/web/Acesso.jsp | 9 ++ trunk/AnaliseAcidentesTrabalho/web/Dummy.jsp | 14 ++- .../web/WEB-INF/navigation.xml | 14 ++- 14 files changed, 280 insertions(+), 23 deletions(-) diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData b/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData index 6bc91625..84ffcf95 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData @@ -2,15 +2,15 @@ - + - + - + @@ -20,8 +20,8 @@ - + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Acesso.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Acesso.java index 0530fed1..74176c52 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Acesso.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Acesso.java @@ -7,10 +7,13 @@ package analiseacidentestrabalho; import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.DropDown; import com.sun.rave.web.ui.component.StaticText; +import db.AnalisesDataProvider; import db.UtilizadoresDataProvider; import global.Global; import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; import javax.faces.context.FacesContext; import utils.JSFUtils; import utils.Utils; @@ -43,6 +46,24 @@ public class Acesso extends AbstractPageBean { public void setStWelcome(StaticText st) { this.stWelcome = st; } + private DropDown drpEstabelecimentos = new DropDown(); + + public DropDown getDrpEstabelecimentos() { + return drpEstabelecimentos; + } + + public void setDrpEstabelecimentos(DropDown dd) { + this.drpEstabelecimentos = dd; + } + private HtmlPanelGrid gridEstabelecimento = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridEstabelecimento() { + return gridEstabelecimento; + } + + public void setGridEstabelecimento(HtmlPanelGrid hpg) { + this.gridEstabelecimento = hpg; + } // @@ -118,6 +139,16 @@ public class Acesso extends AbstractPageBean { //System.out.println("NOME UNICODE : " + nomeUnicode); String nomeHtml = Utils.unicodeToHTML( u.getNome() ); stWelcome.setText("Bem vindo(a) " + nomeHtml); + + if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR) + { + initializeEstabelecimentos(); + } + else + { + gridEstabelecimento.setRendered(false); + } + } /** @@ -200,9 +231,29 @@ public class Acesso extends AbstractPageBean { switch(permissao.intValue()) { case 1: //seguranca - return "form_seguranca"; + return "form_seguranca"; + case 2: //rh + return "form_rh"; case 3: //hs - return "form_hs"; + return "form_hs"; + case 6: //gestor + Integer estabelecimento = null; + if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR) + { + estabelecimento = (Integer) drpEstabelecimentos.getSelected(); + // if(estabelecimento.intValue() == -1) + // { + // getSessionBean1().setMsg("Falta estabelecimento!"); + // return null; + // } + // else + // { + // u.setEstabelecimento(estabelecimento_outro); + u.setEstabelecimento_gestor(estabelecimento); + } + return "form_gestor"; + case 7: //dir ger rh + return "form_dir_ger_rh"; case 8: //dir_siprp return "form_dir_siprp"; default: @@ -223,8 +274,25 @@ public class Acesso extends AbstractPageBean { Utilizador u = getSessionBean1().getCurrentUser(); // String curUser = "?user=" + u.getId().toString(); - FacesContext fc = getFacesContext().getCurrentInstance(); - Global.redirectToPlanos(fc, u); + FacesContext fc = getFacesContext().getCurrentInstance(); + + Integer estabelecimento = null; + if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR) + { + estabelecimento = (Integer) drpEstabelecimentos.getSelected(); +// if(estabelecimento.intValue() == -1) +// { +// getSessionBean1().setMsg("Falta estabelecimento!"); +// return null; +// } +// else +// { +// u.setEstabelecimento(estabelecimento_outro); + u.setEstabelecimento_gestor(estabelecimento); + } + + + Global.redirectToPlanos(fc, u); // FacesContext fc = getFacesContext().getCurrentInstance(); // Utilizador u = getSessionBean1().getCurrentUser(); @@ -240,6 +308,24 @@ public class Acesso extends AbstractPageBean { return null; } + + private void initializeEstabelecimentos() + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + com.sun.rave.web.ui.model.Option[] listGestorOptions = adp.getEstabelecimentosGestorList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(true)); + //listGestorOptions[0].setLabel("-Seleccionar-"); + + + getSessionBean1().setEstabelecimentosGestorOptions( listGestorOptions ); + drpEstabelecimentos.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java index c2d67e2a..8e27c573 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java @@ -11606,8 +11606,15 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean { if(txtCoefIncapacidade.getText() != null) { String coef_str = txtCoefIncapacidade.getText().toString(); - int coef = Integer.parseInt(coef_str); - a.setCoef_incapacidade(new Integer(coef)); + try + { + int coef = Integer.parseInt(coef_str); + a.setCoef_incapacidade(new Integer(coef)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } } DateFormat formatador = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Dummy.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Dummy.java index 193fad43..863ff953 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Dummy.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Dummy.java @@ -148,6 +148,15 @@ public class Dummy extends AbstractPageBean { public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) { this.dropDown1DefaultOptions = ssol; } + private SingleSelectOptionsList dropDown2DefaultOptions = new SingleSelectOptionsList(); + + public SingleSelectOptionsList getDropDown2DefaultOptions() { + return dropDown2DefaultOptions; + } + + public void setDropDown2DefaultOptions(SingleSelectOptionsList ssol) { + this.dropDown2DefaultOptions = ssol; + } // diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java index c550ab1e..3b258afa 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java @@ -911,14 +911,29 @@ public class FormGestor extends AbstractPageBean { AnalisesDataProvider adp = new AnalisesDataProvider(); try { + Integer estabelecimento_id = null; //lblActivos.setRendered(true); table1.setRendered(true); ArrayList seguimentoList = null; - if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA) + //if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA) + if(curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR) + { + estabelecimento_id = curUser.getEstabelecimento_gestor(); + if(estabelecimento_id.intValue() == 0) + { + seguimentoList = adp.getAnalisesSeguimentoGestorList(null); + } + else + { + seguimentoList = adp.getAnalisesSeguimentoGestorList(curUser.getEstabelecimento_id()); + } + } + + else if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA) { seguimentoList = adp.getAnalisesSeguimentoGestorList(null); } - else if(curUser.getGestor_geral().matches("n") ) + else if(curUser.getGestor_geral().matches("n") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA) { seguimentoList = adp.getAnalisesSeguimentoGestorList(curUser.getEstabelecimento_id()); } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java index adc3a3b3..40bd21e4 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java @@ -398,7 +398,15 @@ public class Login extends AbstractPageBean { } else if(permissao.intValue() == 2) // rh { - sRet = "form_rh"; + if(u.getResponsavel_loja().matches("y")) + { + sRet = "acesso"; + } + else + { + sRet = "form_rh"; + } + //sRet = "form_rh"; } else if(permissao.intValue() == 3) // hs { @@ -411,12 +419,14 @@ public class Login extends AbstractPageBean { } else if(permissao.intValue() == 6) // gestor { - sRet = "form_gestor"; + //sRet = "form_gestor"; + sRet = "acesso"; } else if(permissao.intValue() == 7) // director geral rh { //sRet = "form_rh"; - sRet = "form_dir_ger_rh"; + //sRet = "form_dir_ger_rh"; + sRet = "acesso"; } else if(permissao.intValue() == 8) // director siprp { diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java index 33dd4c8f..5fe5c2fb 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java @@ -438,7 +438,28 @@ public class SessionBean1 extends AbstractSessionBean { public void setEstabelecimentosOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosOptions) { this.estabelecimentosOptions = estabelecimentosOptions; - } + } + + private Integer estabelecimentoGestorChoice; + + public Integer getEstabelecimentoGestorChoice() { + return estabelecimentoGestorChoice; + } + + public void setEstabelecimentoGestorChoice(Integer estabelecimentoGestorChoice) { + this.estabelecimentoGestorChoice = estabelecimentoGestorChoice; + } + + private com.sun.rave.web.ui.model.Option[] estabelecimentosGestorOptions; + + public com.sun.rave.web.ui.model.Option[] getEstabelecimentosGestorOptions() { + return estabelecimentosGestorOptions; + } + + public void setEstabelecimentosGestorOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosGestorOptions) { + this.estabelecimentosGestorOptions = estabelecimentosGestorOptions; + } + // @@ -451,6 +472,8 @@ public class SessionBean1 extends AbstractSessionBean { public void setEstabelecimentoOutroChoice(Integer estabelecimentoOutroChoice) { this.estabelecimentoOutroChoice = estabelecimentoOutroChoice; } + + private com.sun.rave.web.ui.model.Option[] estabelecimentosOutroOptions; diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java index 6e375480..e0f723b8 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java @@ -49,6 +49,8 @@ public class Utilizador { private String apagado; private Date data_password; + + private Integer estabelecimento_gestor = null; /** Creates a new instance of Utilizador */ public Utilizador() { @@ -245,5 +247,19 @@ public class Utilizador { public void setData_password(Date data_password) { this.data_password = data_password; } + + /** + * @return the estabelecimento_gestor + */ + public Integer getEstabelecimento_gestor() { + return estabelecimento_gestor; + } + + /** + * @param estabelecimento_gestor the estabelecimento_gestor to set + */ + public void setEstabelecimento_gestor(Integer estabelecimento_gestor) { + this.estabelecimento_gestor = estabelecimento_gestor; + } } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java index 4dc2ebcd..42037d0f 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java @@ -1883,7 +1883,61 @@ public class AnalisesDataProvider { } dblocal.close(); return listOptions; - } + } + + public com.sun.rave.web.ui.model.Option[] getEstabelecimentosGestorList(Integer empresa_id, Boolean booGestor) throws Exception + { + Dblocal dblocal = new Dblocal(); + dblocal.connect(); + Statement stlocal = dblocal.createStatement(); + ArrayList list = new ArrayList(); + Estabelecimento e = null; + //Estabelecimento e = new Estabelecimento(); + //e.setId(new Integer(-1)); + + //e.setNome("-Seleccionar-"); + + //list.add(e); + if(booGestor.equals(new Boolean(true))) + { + e = new Estabelecimento(); + e.setId(new Integer(0)); + e.setNome("-Todos os estabelecimentos-"); + + list.add(e); + } + String sql ="SELECT * FROM estabelecimentos WHERE empresa_id = " + empresa_id + " AND inactivo = 'n' ORDER BY nome_plain"; + + ResultSet rslocal = stlocal.executeQuery(sql); + if(rslocal.isBeforeFirst()) + { + rslocal.first(); + do + { + e = new Estabelecimento(); + e.setId(new Integer(rslocal.getInt("id"))); + //e.setNome_plain(rslocal.getString("nome_plain")); + e.setNome(rslocal.getString("nome")); + System.out.println("ESTABELECIMENTOAA : " + e.getId().toString() + " - " + e.getNome()); + //t.setActivo(rs.getString("activo")); + //t.setOrdem(new Integer(rs.getInt("ordem"))); + list.add(e); + }while(rslocal.next()); + } + + com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[list.size()]; + ListIterator iter = list.listIterator(); + int i = 0; + while(iter.hasNext()) + { + e = (Estabelecimento) iter.next(); + System.out.println("ESTABELECIMENTOL : " + e.getId().toString() + " - " + e.getNome()); + listOptions[i] = new Option(e.getId(), Utils.unicodeToHTML(e.getNome())); + i++; + } + dblocal.close(); + return listOptions; + } public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception { diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java index 565bfe3f..48fa4e63 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java @@ -22,7 +22,7 @@ import javax.servlet.http.HttpSession; */ public class Dblocal { //String connectionURL = "jdbc:postgresql://storage/siprp_local"; //testes - String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3"; + String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3"; String User = "postgres"; String Pass = null; Connection connection = null; diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java b/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java index 23f39469..79bebc5b 100755 --- a/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java @@ -145,11 +145,17 @@ public class Global { public static void redirectToPlanos(FacesContext fc, Utilizador currentUser) { - String curUser = "?user=" + currentUser.getId().toString(); + String curUser = "?user=" + currentUser.getId().toString(); + String estab = ""; + if(currentUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR) + { + //obtem estabelecimento da lista de estabelecimentos + estab = "&estab_gestor=" + currentUser.getEstabelecimento_gestor().intValue(); + } fc = fc.getCurrentInstance(); try { - JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser); + JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser + estab); //JSFUtils.dispatch(fc, Global.PLANOS_ACTUACAO_URL + curUser); } catch(Exception ex) diff --git a/trunk/AnaliseAcidentesTrabalho/web/Acesso.jsp b/trunk/AnaliseAcidentesTrabalho/web/Acesso.jsp index cf5cfe7d..e2a639ab 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/Acesso.jsp +++ b/trunk/AnaliseAcidentesTrabalho/web/Acesso.jsp @@ -42,6 +42,15 @@ + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/Dummy.jsp b/trunk/AnaliseAcidentesTrabalho/web/Dummy.jsp index b02d7983..d8921857 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/Dummy.jsp +++ b/trunk/AnaliseAcidentesTrabalho/web/Dummy.jsp @@ -63,8 +63,18 @@ - - + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml index 5266d92b..5e0f02a0 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml +++ b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml @@ -423,6 +423,14 @@ gestor /FormGestor.jsp + + form_rh + /FormRH.jsp + + + form_dir_ger_rh + /FormDirGerRh.jsp + form_hs /FormHS.jsp @@ -434,7 +442,11 @@ form_dir_siprp /FormDirSiprp.jsp - + + + form_gestor + /FormGestor.jsp + login /Login.jsp