diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Causa.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Causa.java new file mode 100644 index 00000000..35f0ef4e --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Causa.java @@ -0,0 +1,40 @@ +/* + * Causa.java + * + * Created on November 27, 2007, 4:21 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Causa { + private Integer id; + private String causa; + + /** Creates a new instance of Causa */ + public Causa() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getCausa() { + return causa; + } + + public void setCausa(String causa) { + this.causa = causa; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Controle.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Controle.java new file mode 100644 index 00000000..eecef399 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Controle.java @@ -0,0 +1,49 @@ +/* + * Controle.java + * + * Created on January 7, 2008, 3:03 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Controle { + private Integer id; + private Integer analise_year; + private Integer last_analise_nr; + + /** Creates a new instance of Controle */ + public Controle() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getAnalise_year() { + return analise_year; + } + + public void setAnalise_year(Integer analise_year) { + this.analise_year = analise_year; + } + + public Integer getLast_analise_nr() { + return last_analise_nr; + } + + public void setLast_analise_nr(Integer last_analise_nr) { + this.last_analise_nr = last_analise_nr; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Correcao.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Correcao.java new file mode 100644 index 00000000..5df8a389 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Correcao.java @@ -0,0 +1,75 @@ +/* + * Correcao.java + * + * Created on November 29, 2007, 10:42 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Correcao { + private Integer analise_id; + private String correcao; // 'y'/ 'n' + private Integer estado_actual; + private Integer estado_corr; + private String descricao; //descricao do estado a corrigir + private String observacoes; + /** Creates a new instance of Correcao */ + public Correcao() { + } + + public Integer getEstado_actual() { + return estado_actual; + } + + public void setEstado_actual(Integer estado_actual) { + this.estado_actual = estado_actual; + } + + public Integer getEstado_corr() { + return estado_corr; + } + + public void setEstado_corr(Integer estado_corr) { + this.estado_corr = estado_corr; + } + + public String getObservacoes() { + return observacoes; + } + + public void setObservacoes(String observacoes) { + this.observacoes = observacoes; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public Integer getAnalise_id() { + return analise_id; + } + + public void setAnalise_id(Integer analise_id) { + this.analise_id = analise_id; + } + + public String getCorrecao() { + return correcao; + } + + public void setCorrecao(String correcao) { + this.correcao = correcao; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Departamento.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Departamento.java new file mode 100644 index 00000000..5fdff6a2 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Departamento.java @@ -0,0 +1,49 @@ +/* + * Departamento.java + * + * Created on December 28, 2007, 11:16 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Departamento { + private Integer id; + private String descricao; + private String activo; + + /** Creates a new instance of Departamento */ + public Departamento() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public String getActivo() { + return activo; + } + + public void setActivo(String activo) { + this.activo = activo; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EditUser.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EditUser.java new file mode 100644 index 00000000..70fe873c --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EditUser.java @@ -0,0 +1,22 @@ +/* + * EditUser.java + * + * Created on December 5, 2007, 2:02 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class EditUser extends Utilizador{ + + /** Creates a new instance of EditUser */ + public EditUser() { + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EnviarCorrecao.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EnviarCorrecao.java new file mode 100644 index 00000000..173f5453 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EnviarCorrecao.java @@ -0,0 +1,753 @@ +/* + * EnviarCorrecao.java + * + * Created on November 28, 2007, 5:27 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextArea; +import db.AnalisesDataProvider; +import db.EstadosCorrecaoDataProvider; +import global.Global; +import java.util.ArrayList; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class EnviarCorrecao extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser1 = new StaticText(); + + public StaticText getLblUser1() { + return lblUser1; + } + + public void setLblUser1(StaticText st) { + this.lblUser1 = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser1 = new Hyperlink(); + + public Hyperlink getLnkEditUser1() { + return lnkEditUser1; + } + + public void setLnkEditUser1(Hyperlink h) { + this.lnkEditUser1 = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout1 = new Hyperlink(); + + public Hyperlink getLnkLogout1() { + return lnkLogout1; + } + + public void setLnkLogout1(Hyperlink h) { + this.lnkLogout1 = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private HtmlPanelGrid gridMain1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMain1() { + return gridMain1; + } + + public void setGridMain1(HtmlPanelGrid hpg) { + this.gridMain1 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private TextArea txtObservacoes = new TextArea(); + + public TextArea getTxtObservacoes() { + return txtObservacoes; + } + + public void setTxtObservacoes(TextArea ta) { + this.txtObservacoes = ta; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkEstadoCorr = new Hyperlink(); + + public Hyperlink getLnkEstadoCorr() { + return lnkEstadoCorr; + } + + public void setLnkEstadoCorr(Hyperlink h) { + this.lnkEstadoCorr = h; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public EnviarCorrecao() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("EnviarCorrecao Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + + + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + fillTabelaEstados(); + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPor_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkFase_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + return null; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + return null; + } + + private void fillTabelaEstados() + { + ArrayList list = new ArrayList(); + Correcao c = null; + int estado = getSessionBean1().getCurrentAnalise().getEstado().intValue(); + + switch(estado) + { + case Global.ESTADO_HS: + c = new Correcao(); + c.setCorrecao("y"); + c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); + c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); + c.setEstado_corr(new Integer(Global.ESTADO_SEG)); + c.setDescricao("FASE 1 - SEG - ABERTURA"); + list.add(c); + c = new Correcao(); + c.setCorrecao("y"); + c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); + c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); + c.setEstado_corr(new Integer(Global.ESTADO_RH1)); + c.setDescricao("FASE 2 - RH - ACOMPANHAMENTO"); + list.add(c); + getSessionBean1().getEstadosCorrecaoDataProvider().setList(list); + break; + case Global.ESTADO_CONSOLIDACAO: + c = new Correcao(); + c.setCorrecao("y"); + c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); + c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); + c.setEstado_corr(new Integer(Global.ESTADO_RH2)); + c.setDescricao("FASE 4 - RH - MEDIDAS + LESÃO"); + list.add(c); +// c = new Correcao(); +// c.setCorrecao("y"); +// c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); +// c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); +// c.setEstado_corr(new Integer(Global.ESTADO_MEDICINA)); +// c.setDescricao("Medicina"); +// list.add(c); + getSessionBean1().getEstadosCorrecaoDataProvider().setList(list); + break; + } + } + + public String lnkEstadoCorr_action() { + // TODO: Replace with your code + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + EstadosCorrecaoDataProvider provider = (EstadosCorrecaoDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + Correcao c = (Correcao)list.get(k); + c.setObservacoes(""); + if(txtObservacoes.getText() != null) + { + String obs = (String) txtObservacoes.getText(); + c.setObservacoes(obs); + } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + adp.changeEstado(c); + + } + catch(Exception ex) + { + ex.printStackTrace(); + } + return "form_hs"; + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + //return "form_hs"; + return "analise_acidente"; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estado.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estado.java new file mode 100644 index 00000000..d7354742 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estado.java @@ -0,0 +1,39 @@ +/* + * Estado.java + * + * Created on November 29, 2007, 10:01 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Estado { + private Integer estado; + private String descricao; + /** Creates a new instance of Estado */ + public Estado() { + } + + public Integer getEstado() { + return estado; + } + + public void setEstado(Integer estado) { + this.estado = estado; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirGerRh.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirGerRh.java new file mode 100644 index 00000000..ef14826e --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirGerRh.java @@ -0,0 +1,1336 @@ +/* + * FormDirGerRh.java + * + * Created on December 19, 2007, 11:48 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesConcluidasDataProvider; +import db.AnalisesDataProvider; +import db.AnalisesSeguimentoDataProvider; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class FormDirGerRh extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText stSep1 = new StaticText(); + + public StaticText getStSep1() { + return stSep1; + } + + public void setStSep1(StaticText st) { + this.stSep1 = st; + } + + private Hyperlink lnkAnalisesAcidente1 = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente1() { + return lnkAnalisesAcidente1; + } + + public void setLnkAnalisesAcidente1(Hyperlink h) { + this.lnkAnalisesAcidente1 = h; + } + + private StaticText stSep2 = new StaticText(); + + public StaticText getStSep2() { + return stSep2; + } + + public void setStSep2(StaticText st) { + this.stSep2 = st; + } + + private Hyperlink lnkGerirUtilizadores = new Hyperlink(); + + public Hyperlink getLnkGerirUtilizadores() { + return lnkGerirUtilizadores; + } + + public void setLnkGerirUtilizadores(Hyperlink h) { + this.lnkGerirUtilizadores = h; + } + + private StaticText stSep3 = new StaticText(); + + public StaticText getStSep3() { + return stSep3; + } + + public void setStSep3(StaticText st) { + this.stSep3 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridSeguimento1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento1() { + return gridSeguimento1; + } + + public void setGridSeguimento1(HtmlPanelGrid hpg) { + this.gridSeguimento1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public FormDirGerRh() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("FormDirGerRh Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoDirGerRhList(); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormDirGerRh.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList concluidasList = adp.getAnalisesConcluidasList(null); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkAnalisesAcidente_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormDirGerRh"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + //fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(null, ano, mes, dia, por, nome); + + table2.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table2.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirGerRh"); + return "view_analise"; + + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + + public String lnkGerirUtilizadores_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormDirGerRh"); + //getSessionBean1().setModoEdicaoUtilizador("new"); + return "gestao_utilizadores"; + + } + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + +// private void fillDiaDropDown() +// { +// +// } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java new file mode 100755 index 00000000..d23f08b3 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java @@ -0,0 +1,1345 @@ +/* + * FormDirSiprp.java + * + * Created on November 21, 2007, 1:25 PM + * Copyright lluis2 + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesConcluidasDataProvider; +import db.AnalisesDataProvider; +import db.AnalisesSeguimentoDataProvider; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class FormDirSiprp extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText stSep1 = new StaticText(); + + public StaticText getStSep1() { + return stSep1; + } + + public void setStSep1(StaticText st) { + this.stSep1 = st; + } + + private Hyperlink lnkNewUser = new Hyperlink(); + + public Hyperlink getLnkNewUser() { + return lnkNewUser; + } + + public void setLnkNewUser(Hyperlink h) { + this.lnkNewUser = h; + } + + private StaticText stSep2 = new StaticText(); + + public StaticText getStSep2() { + return stSep2; + } + + public void setStSep2(StaticText st) { + this.stSep2 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridSeguimento1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento1() { + return gridSeguimento1; + } + + public void setGridSeguimento1(HtmlPanelGrid hpg) { + this.gridSeguimento1 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn12 = new TableColumn(); + + public TableColumn getTableColumn12() { + return tableColumn12; + } + + public void setTableColumn12(TableColumn tc) { + this.tableColumn12 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private StaticText stSep3 = new StaticText(); + + public StaticText getStSep3() { + return stSep3; + } + + public void setStSep3(StaticText st) { + this.stSep3 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public FormDirSiprp() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("FormDirSiprp Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoDirSiprpList(); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormDirSiprp.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table3.setRendered(true); + + ArrayList concluidasList = adp.getAnalisesConcluidasList(null); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table3.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + //} + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormDirSiprp"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPor_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkFase_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + //fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(null, ano, mes, dia, por, nome); + + table3.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table3.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormDirSiprp"); + return "view_analise"; + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormDirSiprp"); + //getSessionBean1().setModoEdicaoUtilizador("new"); + return "gestao_utilizadores"; + } + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + +// private void fillDiaDropDown() +// { +// +// } + + +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java new file mode 100644 index 00000000..8909307b --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormGestor.java @@ -0,0 +1,1354 @@ +/* + * FormGestor.java + * + * Created on December 19, 2007, 3:58 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesConcluidasDataProvider; +import db.AnalisesDataProvider; +import db.AnalisesSeguimentoDataProvider; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class FormGestor extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText stSep1 = new StaticText(); + + public StaticText getStSep1() { + return stSep1; + } + + public void setStSep1(StaticText st) { + this.stSep1 = st; + } + + private Hyperlink lnkAnalisesAcidente1 = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente1() { + return lnkAnalisesAcidente1; + } + + public void setLnkAnalisesAcidente1(Hyperlink h) { + this.lnkAnalisesAcidente1 = h; + } + + private StaticText stSep2 = new StaticText(); + + public StaticText getStSep2() { + return stSep2; + } + + public void setStSep2(StaticText st) { + this.stSep2 = st; + } + + private Hyperlink lnkGerirUtilizadores = new Hyperlink(); + + public Hyperlink getLnkGerirUtilizadores() { + return lnkGerirUtilizadores; + } + + public void setLnkGerirUtilizadores(Hyperlink h) { + this.lnkGerirUtilizadores = h; + } + + private StaticText stSep3 = new StaticText(); + + public StaticText getStSep3() { + return stSep3; + } + + public void setStSep3(StaticText st) { + this.stSep3 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridSeguimento1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento1() { + return gridSeguimento1; + } + + public void setGridSeguimento1(HtmlPanelGrid hpg) { + this.gridSeguimento1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public FormGestor() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("FormGestor Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + ArrayList seguimentoList = null; + if(getSessionBean1().getCurrentUser().getGestor_geral().matches("y")) + { + seguimentoList = adp.getAnalisesSeguimentoGestorList(null); + } + else + { + seguimentoList = adp.getAnalisesSeguimentoGestorList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + } + + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormGestor.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + ArrayList concluidasList = null; + if(getSessionBean1().getCurrentUser().getGestor_geral().matches("y")) + { + concluidasList = adp.getAnalisesConcluidasList(null); + } + else + { + concluidasList = adp.getAnalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + } + + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkAnalisesAcidente_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkGerirUtilizadores_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormGestor"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + //fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = null; + if(getSessionBean1().getCurrentUser().getGestor_geral().matches("y")) + { + concluidasList = adp.searchAanalisesConcluidasList(null, ano, mes, dia, por, nome); + } + else + { + concluidasList = adp.searchAanalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), ano, mes, dia, por, nome); + } + + + table2.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table2.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormGestor"); + return "view_analise"; + + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + +// private void fillDiaDropDown() +// { +// +// } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/GestaoUtilizadores.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/GestaoUtilizadores.java new file mode 100644 index 00000000..f196fa68 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/GestaoUtilizadores.java @@ -0,0 +1,1254 @@ +/* + * GestaoUtilizadores.java + * + * Created on November 30, 2007, 1:34 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.SingleSelectOptionsList; +import db.AnalisesDataProvider; +import db.UtilizadoresActivosListDataProvider; +import db.UtilizadoresDataProvider; +import db.UtilizadoresInactivosListDataProvider; +import global.Global; +import java.util.ArrayList; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class GestaoUtilizadores extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText stSep1 = new StaticText(); + + public StaticText getStSep1() { + return stSep1; + } + + public void setStSep1(StaticText st) { + this.stSep1 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText stSep2 = new StaticText(); + + public StaticText getStSep2() { + return stSep2; + } + + public void setStSep2(StaticText st) { + this.stSep2 = st; + } + + private Hyperlink lnkEditUser1 = new Hyperlink(); + + public Hyperlink getLnkEditUser1() { + return lnkEditUser1; + } + + public void setLnkEditUser1(Hyperlink h) { + this.lnkEditUser1 = h; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkLogout1 = new Hyperlink(); + + public Hyperlink getLnkLogout1() { + return lnkLogout1; + } + + public void setLnkLogout1(Hyperlink h) { + this.lnkLogout1 = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkCategoriaActivos = new Hyperlink(); + + public Hyperlink getLnkCategoriaActivos() { + return lnkCategoriaActivos; + } + + public void setLnkCategoriaActivos(Hyperlink h) { + this.lnkCategoriaActivos = h; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private Hyperlink lnkPorActivos = new Hyperlink(); + + public Hyperlink getLnkPorActivos() { + return lnkPorActivos; + } + + public void setLnkPorActivos(Hyperlink h) { + this.lnkPorActivos = h; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private Hyperlink lnkNomeActivos = new Hyperlink(); + + public Hyperlink getLnkNomeActivos() { + return lnkNomeActivos; + } + + public void setLnkNomeActivos(Hyperlink h) { + this.lnkNomeActivos = h; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkEstabelecimentoActivos = new Hyperlink(); + + public Hyperlink getLnkEstabelecimentoActivos() { + return lnkEstabelecimentoActivos; + } + + public void setLnkEstabelecimentoActivos(Hyperlink h) { + this.lnkEstabelecimentoActivos = h; + } + + private StaticText txtSearchMsg1 = new StaticText(); + + public StaticText getTxtSearchMsg1() { + return txtSearchMsg1; + } + + public void setTxtSearchMsg1(StaticText st) { + this.txtSearchMsg1 = st; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkPorInactivos = new Hyperlink(); + + public Hyperlink getLnkPorInactivos() { + return lnkPorInactivos; + } + + public void setLnkPorInactivos(Hyperlink h) { + this.lnkPorInactivos = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNomeInactivos = new Hyperlink(); + + public Hyperlink getLnkNomeInactivos() { + return lnkNomeInactivos; + } + + public void setLnkNomeInactivos(Hyperlink h) { + this.lnkNomeInactivos = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkCategoriaInactivos = new Hyperlink(); + + public Hyperlink getLnkCategoriaInactivos() { + return lnkCategoriaInactivos; + } + + public void setLnkCategoriaInactivos(Hyperlink h) { + this.lnkCategoriaInactivos = h; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkEstabelecimentoInactivos = new Hyperlink(); + + public Hyperlink getLnkEstabelecimentoInactivos() { + return lnkEstabelecimentoInactivos; + } + + public void setLnkEstabelecimentoInactivos(Hyperlink h) { + this.lnkEstabelecimentoInactivos = h; + } + + private StaticText txtSearchMsg2 = new StaticText(); + + public StaticText getTxtSearchMsg2() { + return txtSearchMsg2; + } + + public void setTxtSearchMsg2(StaticText st) { + this.txtSearchMsg2 = st; + } + + private DropDown drpEstabelecimentos = new DropDown(); + + public DropDown getDrpEstabelecimentos() { + return drpEstabelecimentos; + } + + public void setDrpEstabelecimentos(DropDown dd) { + this.drpEstabelecimentos = dd; + } + + private SingleSelectOptionsList drpEstabelecimentosDefaultOptions = new SingleSelectOptionsList(); + + public SingleSelectOptionsList getDrpEstabelecimentosDefaultOptions() { + return drpEstabelecimentosDefaultOptions; + } + + public void setDrpEstabelecimentosDefaultOptions(SingleSelectOptionsList ssol) { + this.drpEstabelecimentosDefaultOptions = ssol; + } + + //
+ boolean isPostback = false; + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Button butNovoUtilizador = new Button(); + + public Button getButNovoUtilizador() { + return butNovoUtilizador; + } + + public void setButNovoUtilizador(Button b) { + this.butNovoUtilizador = b; + } + + private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg1() { + return gridMsg1; + } + + public void setGridMsg1(HtmlPanelGrid hpg) { + this.gridMsg1 = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private StaticText stSep3 = new StaticText(); + + public StaticText getStSep3() { + return stSep3; + } + + public void setStSep3(StaticText st) { + this.stSep3 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + /** + *

Construct a new Page bean instance.

+ */ + public GestaoUtilizadores() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("GestaoUtilizadores Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + else + { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + + boolean userDeleted = getSessionBean1().isUserDeleted(); + + if(userDeleted) + { + getSessionBean1().setUserDeleted(false); + } + + if(!pageFrom.matches("GestaoUtilizadores.jsp") || userDeleted) + { + isPostback = false; + } + else + { + isPostback = true; + } + } + + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + AnalisesDataProvider adp = new AnalisesDataProvider(); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + + if(!isPostback) + { + try + { + com.sun.rave.web.ui.model.Option[] listOptions = adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false)); + listOptions[0].setLabel("-Todos-"); + getSessionBean1().setEstabelecimentosOptions( listOptions ); + drpEstabelecimentos.setSelected(new Integer(-1)); + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + String isDirRh = "n"; + if(getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) // Director geral rh + { + isDirRh = "y"; + } + try + { + ArrayList list = udp.getUtilizadoresList(null, null, null, "y", isDirRh); + getSessionBean1().getUtilizadoresActivosListDataProvider().setList(list); + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + try + { + ArrayList list = udp.getUtilizadoresList(null, null, null, "n", isDirRh); + getSessionBean1().getUtilizadoresInactivosListDataProvider().setList(list); + } + catch(Exception ex) + { + //ex.printStackTrace(); + getSessionBean1().getUtilizadoresInactivosListDataProvider().setList(new ArrayList()); + table1.setRendered(false); + } + + } + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("GestaoUtilizadores"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + + } + + public String butNovaAnalise_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPor_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkFase_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + return null; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + String por = null; + String nome = null; + Integer estabelecimento_id = null; + + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + else + { + por = por.toLowerCase(); + } + } + + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + else + { + nome = nome.toLowerCase(); + } + } + + estabelecimento_id = (Integer) drpEstabelecimentos.getSelected(); + if(estabelecimento_id.intValue() == -1) + { + estabelecimento_id = null; + } + + String isDirRh = "n"; + + if(getSessionBean1().getCurrentUser().getTipo().intValue() == 7) //director geral rh + { + isDirRh = "y"; + } + + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + ArrayList list = udp.getUtilizadoresList(por, nome, estabelecimento_id, "y", isDirRh); + getSessionBean1().getUtilizadoresActivosListDataProvider().setList(list); + } + catch(Exception ex) + { + //ex.printStackTrace(); + getSessionBean1().getUtilizadoresActivosListDataProvider().setList(new ArrayList()); + } + + try + { + ArrayList list = udp.getUtilizadoresList(por, nome, estabelecimento_id, "n", isDirRh); + getSessionBean1().getUtilizadoresInactivosListDataProvider().setList(list); + } + catch(Exception ex) + { + //ex.printStackTrace(); + getSessionBean1().getUtilizadoresInactivosListDataProvider().setList(new ArrayList()); + } + + return null; + } + + public String lnkPorActivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorActivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkNomeActivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorActivoRowData(); + System.out.println("UTILIZADOR ID : " + u.getId()); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkCategoriaActivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorActivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkEstabelecimentosActivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorActivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + private Utilizador getUtilizadorActivoRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + UtilizadoresActivosListDataProvider provider = (UtilizadoresActivosListDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + Utilizador u = (Utilizador)list.get(k); + return u; + } + + + public String lnkPorInactivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorInactivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkNomeInactivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorInactivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkCategoriaInactivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorInactivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + public String lnkEstabelecimentoInactivos_action() { + // TODO: Replace with your code + Utilizador u = getUtilizadorInactivoRowData(); + getSessionBean1().setEditUser(u); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setNavFrom("GestaoUtilizadores"); + return "user_fields"; + } + + private Utilizador getUtilizadorInactivoRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + UtilizadoresInactivosListDataProvider provider = (UtilizadoresInactivosListDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + Utilizador u = (Utilizador)list.get(k); + return u; + } + + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } + + public String butNovoUtilizador_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return "novo_utilizador"; + } + + public String lnkAnalisesAcidente_action() { + // TODO: Replace with your code + String nav_from = getSessionBean1().getNavFrom(); + Integer tipo_utilizador = getSessionBean1().getCurrentUser().getTipo(); + if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP) + { + return "form_dir_siprp"; + } + else if( tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH ) + { + return "form_dir_ger_rh"; + } + return null; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NewUser.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NewUser.java new file mode 100644 index 00000000..3b713ced --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NewUser.java @@ -0,0 +1,176 @@ +/* + * NewUser.java + * + * Created on December 4, 2007, 11:29 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class NewUser { + private Integer tipo; + private String tipo_descricao; + private String nome; + private Integer estabelecimento; + private String estabelecimento_descricao; + private String login; + private String password; + private String email; + + private String numero_mecanografico; + private Integer empresa_id; + private String numero_cedula; + private String cap; + private Integer funcionario_hst_id; + private Integer medico_id; + private String responsavel_loja; + private String gestor_geral; + private String activo; + + /** Creates a new instance of NewUser */ + public NewUser() { + } + + public Integer getTipo() { + return tipo; + } + + public void setTipo(Integer tipo) { + this.tipo = tipo; + } + + public String getTipo_descricao() { + return tipo_descricao; + } + + public void setTipo_descricao(String tipo_descricao) { + this.tipo_descricao = tipo_descricao; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public Integer getEstabelecimento() { + return estabelecimento; + } + + public void setEstabelecimento(Integer estabelecimento) { + this.estabelecimento = estabelecimento; + } + + public String getEstabelecimento_descricao() { + return estabelecimento_descricao; + } + + public void setEstabelecimento_descricao(String estabelecimento_descricao) { + this.estabelecimento_descricao = estabelecimento_descricao; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getNumero_mecanografico() { + return numero_mecanografico; + } + + public void setNumero_mecanografico(String numero_mecanografico) { + this.numero_mecanografico = numero_mecanografico; + } + + public Integer getEmpresa_id() { + return empresa_id; + } + + public void setEmpresa_id(Integer empresa_id) { + this.empresa_id = empresa_id; + } + + public String getNumero_cedula() { + return numero_cedula; + } + + public void setNumero_cedula(String numero_cedula) { + this.numero_cedula = numero_cedula; + } + + public String getCap() { + return cap; + } + + public void setCap(String cap) { + this.cap = cap; + } + + public Integer getFuncionario_hst_id() { + return funcionario_hst_id; + } + + public void setFuncionario_hst_id(Integer funcionario_hst_id) { + this.funcionario_hst_id = funcionario_hst_id; + } + + public Integer getMedico_id() { + return medico_id; + } + + public void setMedico_id(Integer medico_id) { + this.medico_id = medico_id; + } + + public String getResponsavel_loja() { + return responsavel_loja; + } + + public void setResponsavel_loja(String responsavel_loja) { + this.responsavel_loja = responsavel_loja; + } + + public String getActivo() { + return activo; + } + + public void setActivo(String activo) { + this.activo = activo; + } + + public String getGestor_geral() { + return gestor_geral; + } + + public void setGestor_geral(String gestor_geral) { + this.gestor_geral = gestor_geral; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NovoUtilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NovoUtilizador.java new file mode 100644 index 00000000..dad1ab17 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/NovoUtilizador.java @@ -0,0 +1,2042 @@ +/* + * NovoUtilizador.java + * + * Created on December 3, 2007, 2:30 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Checkbox; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.HiddenField; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.RadioButton; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import db.AnalisesDataProvider; +import db.TrabalhadoresListDataProvider; +import global.Global; +import java.util.ArrayList; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class NovoUtilizador extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser1 = new Hyperlink(); + + public Hyperlink getLnkEditUser1() { + return lnkEditUser1; + } + + public void setLnkEditUser1(Hyperlink h) { + this.lnkEditUser1 = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout1 = new Hyperlink(); + + public Hyperlink getLnkLogout1() { + return lnkLogout1; + } + + public void setLnkLogout1(Hyperlink h) { + this.lnkLogout1 = h; + } + + private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg1() { + return gridMsg1; + } + + public void setGridMsg1(HtmlPanelGrid hpg) { + this.gridMsg1 = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private Button butContinuar = new Button(); + + public Button getButContinuar() { + return butContinuar; + } + + public void setButContinuar(Button b) { + this.butContinuar = b; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private HtmlPanelGrid gridCategoria = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridCategoria() { + return gridCategoria; + } + + public void setGridCategoria(HtmlPanelGrid hpg) { + this.gridCategoria = hpg; + } + + private HtmlPanelGrid gridUtilizador = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridUtilizador() { + return gridUtilizador; + } + + public void setGridUtilizador(HtmlPanelGrid hpg) { + this.gridUtilizador = hpg; + } + + private PanelGroup pgCatDirRh = new PanelGroup(); + + public PanelGroup getPgCatDirRh() { + return pgCatDirRh; + } + + public void setPgCatDirRh(PanelGroup pg) { + this.pgCatDirRh = pg; + } + + private RadioButton rbCatDirRh = new RadioButton(); + + public RadioButton getRbCatDirRh() { + return rbCatDirRh; + } + + public void setRbCatDirRh(RadioButton rbCatGestao) { + this.rbCatDirRh = rbCatGestao; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private PanelGroup pgCatGestao = new PanelGroup(); + + public PanelGroup getPgCatGestao() { + return pgCatGestao; + } + + public void setPgCatGestao(PanelGroup pg) { + this.pgCatGestao = pg; + } + + private RadioButton rbCatGestao = new RadioButton(); + + public RadioButton getRbCatGestao() { + return rbCatGestao; + } + + public void setRbCatGestao(RadioButton rbCatGestao) { + this.rbCatGestao = rbCatGestao; + } + + private StaticText staticText12 = new StaticText(); + + public StaticText getStaticText12() { + return staticText12; + } + + public void setStaticText12(StaticText st) { + this.staticText12 = st; + } + + private PanelGroup pgCatGestaoAd = new PanelGroup(); + + public PanelGroup getPgCatGestaoAd() { + return pgCatGestaoAd; + } + + public void setPgCatGestaoAd(PanelGroup pg) { + this.pgCatGestaoAd = pg; + } + + private StaticText staticText13 = new StaticText(); + + public StaticText getStaticText13() { + return staticText13; + } + + public void setStaticText13(StaticText st) { + this.staticText13 = st; + } + + private Checkbox chkGestaoGeral = new Checkbox(); + + public Checkbox getChkGestaoGeral() { + return chkGestaoGeral; + } + + public void setChkGestaoGeral(Checkbox c) { + this.chkGestaoGeral = c; + } + + private PanelGroup pgCatHs = new PanelGroup(); + + public PanelGroup getPgCatHs() { + return pgCatHs; + } + + public void setPgCatHs(PanelGroup pg) { + this.pgCatHs = pg; + } + + private RadioButton rbCatHs = new RadioButton(); + + public RadioButton getRbCatHs() { + return rbCatHs; + } + + public void setRbCatHs(RadioButton rbCatGestao) { + this.rbCatHs = rbCatGestao; + } + + private StaticText staticText14 = new StaticText(); + + public StaticText getStaticText14() { + return staticText14; + } + + public void setStaticText14(StaticText st) { + this.staticText14 = st; + } + + private PanelGroup pgCatMed = new PanelGroup(); + + public PanelGroup getPgCatMed() { + return pgCatMed; + } + + public void setPgCatMed(PanelGroup pg) { + this.pgCatMed = pg; + } + + private RadioButton rbCatMed = new RadioButton(); + + public RadioButton getRbCatMed() { + return rbCatMed; + } + + public void setRbCatMed(RadioButton rbCatGestao) { + this.rbCatMed = rbCatGestao; + } + + private StaticText staticText15 = new StaticText(); + + public StaticText getStaticText15() { + return staticText15; + } + + public void setStaticText15(StaticText st) { + this.staticText15 = st; + } + + private PanelGroup pgCatRh = new PanelGroup(); + + public PanelGroup getPgCatRh() { + return pgCatRh; + } + + public void setPgCatRh(PanelGroup pg) { + this.pgCatRh = pg; + } + + private RadioButton rbCatRh = new RadioButton(); + + public RadioButton getRbCatRh() { + return rbCatRh; + } + + public void setRbCatRh(RadioButton rbCatGestao) { + this.rbCatRh = rbCatGestao; + } + + private StaticText staticText16 = new StaticText(); + + public StaticText getStaticText16() { + return staticText16; + } + + public void setStaticText16(StaticText st) { + this.staticText16 = st; + } + + private PanelGroup pgCatRhAd = new PanelGroup(); + + public PanelGroup getPgCatRhAd() { + return pgCatRhAd; + } + + public void setPgCatRhAd(PanelGroup pg) { + this.pgCatRhAd = pg; + } + + private StaticText staticText17 = new StaticText(); + + public StaticText getStaticText17() { + return staticText17; + } + + public void setStaticText17(StaticText st) { + this.staticText17 = st; + } + + private Checkbox chkRhResp = new Checkbox(); + + public Checkbox getChkRhResp() { + return chkRhResp; + } + + public void setChkRhResp(Checkbox c) { + this.chkRhResp = c; + } + + private PanelGroup pgCatSeg = new PanelGroup(); + + public PanelGroup getPgCatSeg() { + return pgCatSeg; + } + + public void setPgCatSeg(PanelGroup pg) { + this.pgCatSeg = pg; + } + + private RadioButton rbCatSeg = new RadioButton(); + + public RadioButton getRbCatSeg() { + return rbCatSeg; + } + + public void setRbCatSeg(RadioButton rbCatGestao) { + this.rbCatSeg = rbCatGestao; + } + + private StaticText staticText18 = new StaticText(); + + public StaticText getStaticText18() { + return staticText18; + } + + public void setStaticText18(StaticText st) { + this.staticText18 = st; + } + + private PanelGroup pgCatSegAd = new PanelGroup(); + + public PanelGroup getPgCatSegAd() { + return pgCatSegAd; + } + + public void setPgCatSegAd(PanelGroup pg) { + this.pgCatSegAd = pg; + } + + private StaticText staticText19 = new StaticText(); + + public StaticText getStaticText19() { + return staticText19; + } + + public void setStaticText19(StaticText st) { + this.staticText19 = st; + } + + private Checkbox chkSegResp = new Checkbox(); + + public Checkbox getChkSegResp() { + return chkSegResp; + } + + public void setChkSegResp(Checkbox c) { + this.chkSegResp = c; + } + + private HtmlPanelGrid gridTrabalhadores = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTrabalhadores() { + return gridTrabalhadores; + } + + public void setGridTrabalhadores(HtmlPanelGrid hpg) { + this.gridTrabalhadores = hpg; + } + + private StaticText txtSearchMsg1 = new StaticText(); + + public StaticText getTxtSearchMsg1() { + return txtSearchMsg1; + } + + public void setTxtSearchMsg1(StaticText st) { + this.txtSearchMsg1 = st; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private TextField txtNrMecanografico = new TextField(); + + public TextField getTxtNrMecanografico() { + return txtNrMecanografico; + } + + public void setTxtNrMecanografico(TextField tf) { + this.txtNrMecanografico = tf; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private TextField txtNomeTrabalhador = new TextField(); + + public TextField getTxtNomeTrabalhador() { + return txtNomeTrabalhador; + } + + public void setTxtNomeTrabalhador(TextField tf) { + this.txtNomeTrabalhador = tf; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private Button butProcurarTrab = new Button(); + + public Button getButProcurarTrab() { + return butProcurarTrab; + } + + public void setButProcurarTrab(Button b) { + this.butProcurarTrab = b; + } + + private Table tblTrabalhadores = new Table(); + + public Table getTblTrabalhadores() { + return tblTrabalhadores; + } + + public void setTblTrabalhadores(Table t) { + this.tblTrabalhadores = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkPOR = new Hyperlink(); + + public Hyperlink getLnkPOR() { + return lnkPOR; + } + + public void setLnkPOR(Hyperlink h) { + this.lnkPOR = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNomeTrabalhador = new Hyperlink(); + + public Hyperlink getLnkNomeTrabalhador() { + return lnkNomeTrabalhador; + } + + public void setLnkNomeTrabalhador(Hyperlink h) { + this.lnkNomeTrabalhador = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkEstabelecimentoTrabalhador = new Hyperlink(); + + public Hyperlink getLnkEstabelecimentoTrabalhador() { + return lnkEstabelecimentoTrabalhador; + } + + public void setLnkEstabelecimentoTrabalhador(Hyperlink h) { + this.lnkEstabelecimentoTrabalhador = h; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private TextField txtNomeOutro = new TextField(); + + public TextField getTxtNomeOutro() { + return txtNomeOutro; + } + + public void setTxtNomeOutro(TextField tf) { + this.txtNomeOutro = tf; + } + + private StaticText staticText20 = new StaticText(); + + public StaticText getStaticText20() { + return staticText20; + } + + public void setStaticText20(StaticText st) { + this.staticText20 = st; + } + + private DropDown drpEstabelecimentoOutro = new DropDown(); + + public DropDown getDrpEstabelecimentoOutro() { + return drpEstabelecimentoOutro; + } + + public void setDrpEstabelecimentoOutro(DropDown dd) { + this.drpEstabelecimentoOutro = dd; + } + + private HtmlPanelGrid gridTecnicosHs = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTecnicosHs() { + return gridTecnicosHs; + } + + public void setGridTecnicosHs(HtmlPanelGrid hpg) { + this.gridTecnicosHs = hpg; + } + + private StaticText staticText21 = new StaticText(); + + public StaticText getStaticText21() { + return staticText21; + } + + public void setStaticText21(StaticText st) { + this.staticText21 = st; + } + + private DropDown drpNomeHs = new DropDown(); + + public DropDown getDrpNomeHs() { + return drpNomeHs; + } + + public void setDrpNomeHs(DropDown dd) { + this.drpNomeHs = dd; + } + + private StaticText staticText22 = new StaticText(); + + public StaticText getStaticText22() { + return staticText22; + } + + public void setStaticText22(StaticText st) { + this.staticText22 = st; + } + + private TextField txtCap = new TextField(); + + public TextField getTxtCap() { + return txtCap; + } + + public void setTxtCap(TextField tf) { + this.txtCap = tf; + } + + private HtmlPanelGrid gridMedicos = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMedicos() { + return gridMedicos; + } + + public void setGridMedicos(HtmlPanelGrid hpg) { + this.gridMedicos = hpg; + } + + private StaticText staticText23 = new StaticText(); + + public StaticText getStaticText23() { + return staticText23; + } + + public void setStaticText23(StaticText st) { + this.staticText23 = st; + } + + private DropDown drpNomeMed = new DropDown(); + + public DropDown getDrpNomeMed() { + return drpNomeMed; + } + + public void setDrpNomeMed(DropDown dd) { + this.drpNomeMed = dd; + } + + private StaticText staticText24 = new StaticText(); + + public StaticText getStaticText24() { + return staticText24; + } + + public void setStaticText24(StaticText st) { + this.staticText24 = st; + } + + private DropDown drpEstabelecimentoMed = new DropDown(); + + public DropDown getDrpEstabelecimentoMed() { + return drpEstabelecimentoMed; + } + + public void setDrpEstabelecimentoMed(DropDown dd) { + this.drpEstabelecimentoMed = dd; + } + + //
+ boolean isPostback = false; + + private HiddenField hidHighlight = new HiddenField(); + + public HiddenField getHidHighlight() { + return hidHighlight; + } + + public void setHidHighlight(HiddenField hf) { + this.hidHighlight = hf; + } + + private HiddenField hidClear = new HiddenField(); + + public HiddenField getHidClear() { + return hidClear; + } + + public void setHidClear(HiddenField hf) { + this.hidClear = hf; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText25 = new StaticText(); + + public StaticText getStaticText25() { + return staticText25; + } + + public void setStaticText25(StaticText st) { + this.staticText25 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText26 = new StaticText(); + + public StaticText getStaticText26() { + return staticText26; + } + + public void setStaticText26(StaticText st) { + this.staticText26 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText27 = new StaticText(); + + public StaticText getStaticText27() { + return staticText27; + } + + public void setStaticText27(StaticText st) { + this.staticText27 = st; + } + + private StaticText staticText28 = new StaticText(); + + public StaticText getStaticText28() { + return staticText28; + } + + public void setStaticText28(StaticText st) { + this.staticText28 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + /** + *

Construct a new Page bean instance.

+ */ + public NovoUtilizador() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("NovoUtilizador Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + else + { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("NovoUtilizador.jsp")) + { + isPostback = false; + } + else + { + isPostback = true; + } + + } + + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + if(!isPostback) + { + getSessionBean1().setNewUser(null); + initializePage(); + } + else + { + showPagePostback(); + } + + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("NovoUtilizador"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + + } + + public void drpTipo_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpNome_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return "gestao_utilizadores"; + } + + public String butApagar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String butContinuar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + AnalisesDataProvider adp = new AnalisesDataProvider(); + + if(rbCatHs.getSelected() != null) + { + if(rbCatHs.getSelected().equals(new Boolean(true))) + { + if(drpNomeHs.getSelected().equals(new Integer(0) )) + { + getSessionBean1().setMsg("Falta nome do técnico de higiena e segurança!"); + return null; + } + else if(txtCap.getText() == null) + { + getSessionBean1().setMsg("Falta cap!"); + return null; + } + else + { + String cap = (String) txtCap.getText(); + if(cap.trim().length() == 0) + { + getSessionBean1().setMsg("Falta cap!"); + return null; + } + else + { + NewUser u = new NewUser(); + u.setTipo(new Integer(3)); + u.setNumero_mecanografico(""); + try + { + u.setTipo_descricao(adp.getTipoDescricao(u.getTipo())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + u.setFuncionario_hst_id((Integer) drpNomeHs.getSelected()); + try + { + Integer tecnico_id = (Integer) drpNomeHs.getSelected(); + u.setNome(Utils.unicodeToHTML(adp.getTecnicoSaudeNome(tecnico_id))); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + u.setCap(cap); + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setResponsavel_loja("n"); + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + return "new_user_fields"; + } + } + } + } + else if(rbCatMed.getSelected() != null) + { + if(rbCatMed.getSelected().equals(new Boolean(true))) + { + if(drpNomeMed.getSelected().equals(new Integer(0))) + { + getSessionBean1().setMsg("Falta nome do médico!"); + return null; + } + else if(drpEstabelecimentoMed.getSelected().equals(new Integer(-1))) + { + getSessionBean1().setMsg("Falta estabelecimento!"); + return null; + } + else + { + NewUser u = new NewUser(); + u.setTipo(new Integer(5)); + u.setNumero_mecanografico(""); + try + { + u.setTipo_descricao(adp.getTipoDescricao(u.getTipo())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + u.setMedico_id((Integer) drpNomeMed.getSelected()); + //u.setNome(drpNomeMed.getLabel()); + Medico m = null; + try + { + Integer medico_id = (Integer) drpNomeMed.getSelected(); + m = adp.getMedico(medico_id); + u.setNome(m.getNome()); + u.setNumero_cedula(m.getNumero_cedula()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setEstabelecimento((Integer) drpEstabelecimentoMed.getSelected()); + try + { + u.setEstabelecimento_descricao(adp.getEstabelecimentoNome(u.getEstabelecimento())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + u.setResponsavel_loja("n"); + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + return "new_user_fields"; + } + } + } + else // + { + if(getSessionBean1().getNewUser() == null) + { + boolean booOutro = false; + NewUser u = new NewUser(); + if(txtNomeOutro.getText() != null) + { + String nome_outro = (String) txtNomeOutro.getText(); + if(nome_outro.trim().length() > 0) + { + u.setNome(nome_outro); + booOutro = true; + } + else + { + getSessionBean1().setMsg("Falta designação!"); + return null; + } + } + else + { + getSessionBean1().setMsg("Falta designação!"); + return null; + } + Integer estabelecimento_outro = (Integer) drpEstabelecimentoOutro.getSelected(); + if(estabelecimento_outro.intValue() == -1) + { + getSessionBean1().setMsg("Falta estabelecimento!"); + return null; + } + else + { + u.setEstabelecimento(estabelecimento_outro); + try + { + u.setEstabelecimento_descricao(adp.getEstabelecimentoNome(estabelecimento_outro)); + booOutro = true; + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + u = setUserTipo(u); + u.setNumero_mecanografico(""); + u.setResponsavel_loja("n"); + u.setGestor_geral("n"); + switch(u.getTipo().intValue()) + { + case 1: //seg + if(chkSegResp.getSelected() != null) + { + if(chkSegResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + break; + case 2: //rh + if(chkRhResp.getSelected() != null) + { + if(chkRhResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + break; + case 6: //gestor + if(chkGestaoGeral.getSelected() != null) + { + if(chkGestaoGeral.getSelected().equals(new Boolean(true))) + { + u.setGestor_geral("y"); + } + } + + break; + } + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + if(booOutro) + { + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + return "new_user_fields"; + } + getSessionBean1().setNewUser(u); + } + } + + if(getSessionBean1().getNewUser() == null) + { + getSessionBean1().setMsg("Tem de definir um novo utilizador !"); + return null; + } + else + { + + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + return "new_user_fields"; + } + } + + + + private void initializePage() + { + getSessionBean1().getTrabalhadoresListDataProvider().setList(new ArrayList()); + int tipo = getSessionBean1().getCurrentUser().getTipo().intValue(); + switch(tipo) + { + case 7: //Director RH + pgCatDirRh.setRendered(false); + pgCatHs.setRendered(false); + pgCatMed.setRendered(false); + break; + } + + //gridUtilizador.setRendered(false); + gridTrabalhadores.setStyleClass("hidden"); + tblTrabalhadores.setStyleClass("hidden"); + gridTecnicosHs.setStyleClass("hidden"); + gridMedicos.setStyleClass("hidden"); + + rbCatDirRh.setSelected(null); + rbCatGestao.setSelected(null); + rbCatHs.setSelected(null); + rbCatMed.setSelected(null); + rbCatRh.setSelected(null); + rbCatSeg.setSelected(null); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + + try + { + com.sun.rave.web.ui.model.Option[] listMedOptions = adp.getEstabelecimentosList( new Integer(Global.AUCHAN), new Boolean(false)); + listMedOptions[0].setLabel("-Seleccionar-"); + com.sun.rave.web.ui.model.Option[] listOutroOptions = adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false)); + listOutroOptions[0].setLabel("-Seleccionar-"); + + + getSessionBean1().setEstabelecimentosMedOptions(listMedOptions); + getSessionBean1().setEstabelecimentosOutroOptions( listOutroOptions ); + drpEstabelecimentoOutro.setSelected(new Integer(-1)); + drpEstabelecimentoMed.setSelected(new Integer(-1)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + try + { + getSessionBean1().setTecnicosOptions(adp.getTecnicosSaudeList()); + drpNomeHs.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + try + { + getSessionBean1().setMedicosOptions(adp.getMedicosList()); + drpNomeMed.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + public String butProcurarTrab_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + boolean booNrOk = false; + boolean booNomeOk = false; + String nr_mecano = null; + String nome = null; + if(txtNrMecanografico.getText() != null) + { + nr_mecano = (String) txtNrMecanografico.getText(); + if(nr_mecano.trim().length() > 0) + { + booNrOk = true; + } + else + { + nr_mecano = null; + } + } + + if(txtNomeTrabalhador.getText() != null) + { + nome = (String) txtNomeTrabalhador.getText(); + + if(nome.trim().length() > 0) + { + booNomeOk = true; + } + else + { + nome = null; + } + } + + if(! booNrOk && !booNomeOk) + { + getSessionBean1().setMsg("Tem de preencher Numero Mecanográfico ou Nome"); + return null; + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + Trabalhador t = null; + if(nome != null) + { + nome = utils.Utils.textToUnicode( nome.toUpperCase()); + } + try + { + ArrayList list = adp.searchTrabalhador(getSessionBean1().getCurrentUser().getEmpresa_id(), nr_mecano, nome ); +// if(list.size() == 1) +// { +// t = (Trabalhador) list.get(0); +// NewUser u = new NewUser(); +// +// u.setNome(t.getNome()); +// u.setNumero_mecanografico(t.getNumero_mecanografico()); +// u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); +// u.setEstabelecimento(t.getEstabelecimento_id()); +// u.setEstabelecimento_descricao(t.getEstabelecimento()); +// u = setUserTipo(u); +// u.setResponsavel_loja("n"); +// if(u.getTipo().intValue() == 1) //seg +// { +// if(chkSegResp.getSelected() != null) +// { +// if(chkSegResp.getSelected().equals(new Boolean(true))) +// { +// u.setResponsavel_loja("y"); +// } +// } +// } +// else if(u.getTipo().intValue() == 2) //rh +// { +// if(chkRhResp.getSelected() != null) +// { +// if(chkRhResp.getSelected().equals(new Boolean(true))) +// { +// u.setResponsavel_loja("y"); +// } +// } +// } +// getSessionBean1().setNewUser(u); +// } +// else +// { + //tblTrabalhadores.setRendered(true); + gridTrabalhadores.setStyleClass(""); + tblTrabalhadores.setStyleClass(""); + getSessionBean1().getTrabalhadoresListDataProvider().setList(list); +// } + } + catch(Exception ex) + { + getSessionBean1().setMsg("Trabalhador inexistente !"); + getSessionBean1().getTrabalhadoresListDataProvider().setList(new ArrayList()); + tblTrabalhadores.setStyleClass("hidden"); + ex.printStackTrace(); + } + return null; + } + + public String lnkPOR_action() { + // TODO: Replace with your code + Trabalhador t = getTrabalhadorRowData(); + NewUser u = new NewUser(); + u = setUserTipo(u); + u.setNome(t.getNome()); + u.setNumero_mecanografico(t.getNumero_mecanografico()); + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setEstabelecimento(t.getEstabelecimento_id()); + u.setEstabelecimento_descricao(t.getEstabelecimento()); + u.setResponsavel_loja("n"); + u.setGestor_geral("n"); + if(u.getTipo().intValue() == 1) //seg + { + if(chkSegResp.getSelected() != null) + { + if(chkSegResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 2) //rh + { + if(chkRhResp.getSelected() != null) + { + if(chkRhResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 6) //gestor + { + if(chkGestaoGeral.getSelected() != null) + { + if(chkGestaoGeral.getSelected().equals(new Boolean(true))) + { + u.setGestor_geral("y"); + } + } + + } + + + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + + return "new_user_fields"; + } + + public String lnkNomeTrabalhador_action() { + // TODO: Replace with your code + Trabalhador t = getTrabalhadorRowData(); + NewUser u = new NewUser(); + u = setUserTipo(u); + u.setNome(t.getNome()); + u.setNumero_mecanografico(t.getNumero_mecanografico()); + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setEstabelecimento(t.getEstabelecimento_id()); + u.setEstabelecimento_descricao(t.getEstabelecimento()); + u.setResponsavel_loja("n"); + u.setGestor_geral("n"); + if(u.getTipo().intValue() == 1) //seg + { + if(chkSegResp.getSelected() != null) + { + if(chkSegResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 2) //rh + { + if(chkRhResp.getSelected() != null) + { + if(chkRhResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 6) //gestor + { + if(chkGestaoGeral.getSelected() != null) + { + if(chkGestaoGeral.getSelected().equals(new Boolean(true))) + { + u.setGestor_geral("y"); + } + } + + } + + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + + return "new_user_fields"; + } + + public String lnkEstabelecimentoTrabalhador_action() { + // TODO: Replace with your code + Trabalhador t = getTrabalhadorRowData(); + NewUser u = new NewUser(); + u = setUserTipo(u); + u.setNome(t.getNome()); + u.setNumero_mecanografico(t.getNumero_mecanografico()); + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setEstabelecimento(t.getEstabelecimento_id()); + u.setEstabelecimento_descricao(t.getEstabelecimento()); + u.setResponsavel_loja("n"); + u.setGestor_geral("n"); + if(u.getTipo().intValue() == 1) //seg + { + if(chkSegResp.getSelected() != null) + { + if(chkSegResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 2) //rh + { + if(chkRhResp.getSelected() != null) + { + if(chkRhResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + } + else if(u.getTipo().intValue() == 6) //gestor + { + if(chkGestaoGeral.getSelected() != null) + { + if(chkGestaoGeral.getSelected().equals(new Boolean(true))) + { + u.setGestor_geral("y"); + } + } + + } + + getSessionBean1().setNewUser(u); + getSessionBean1().setModoEdicaoUtilizador("new"); + getSessionBean1().setNavFrom("NovoUtilizador"); + + return "new_user_fields"; + } + + private Trabalhador getTrabalhadorRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + Trabalhador t = (Trabalhador)list.get(k); + hidHighlight.setValue(rk.getRowId()); + return t; + } + + private NewUser setUserTipo(NewUser u) + { + if(rbCatDirRh.getSelected() != null) + { + if(rbCatDirRh.getSelected().equals(new Boolean(true))) + { + u.setTipo(new Integer(7)); + } + } + else if(rbCatGestao.getSelected() != null) + { + if(rbCatGestao.getSelected().equals(new Boolean(true))) + { + u.setTipo(new Integer(6)); + } + } + else if(rbCatRh.getSelected() != null) + { + if(rbCatRh.getSelected().equals(new Boolean(true))) + { + u.setTipo(new Integer(2)); + } + } + else if(rbCatSeg.getSelected() != null) + { + if(rbCatSeg.getSelected().equals(new Boolean(true))) + { + u.setTipo(new Integer(1)); + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + u.setTipo_descricao(adp.getTipoDescricao(u.getTipo())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + return u; + } + + private void showPagePostback() + { + if(rbCatDirRh.getSelected() != null) + { + if(rbCatDirRh.getSelected().equals( new Boolean(true) )) + { + gridTrabalhadores.setStyleClass(""); + return; + } + } + + if(rbCatGestao.getSelected() != null) + { + if(rbCatGestao.getSelected().equals( new Boolean(true) )) + { + gridTrabalhadores.setStyleClass(""); + return; + } + } + + if(rbCatRh.getSelected() != null) + { + if(rbCatRh.getSelected().equals( new Boolean(true) )) + { + gridTrabalhadores.setStyleClass(""); + return; + } + } + if(rbCatSeg.getSelected() != null) + { + if(rbCatSeg.getSelected().equals( new Boolean(true) )) + { + gridTrabalhadores.setStyleClass(""); + return; + } + } + + if(rbCatHs.getSelected() != null) + { + if(rbCatHs.getSelected().equals( new Boolean(true) )) + { + gridTecnicosHs.setStyleClass(""); + return; + } + } + + if(rbCatMed.getSelected() != null) + { + if(rbCatMed.getSelected().equals( new Boolean(true) )) + { + gridMedicos.setStyleClass(""); + return; + } + } + + } + +// public String getColumnStyle(){ +// TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow"); +// RowKey rowKey = trdp.getTableRow(); +// System.out.println(rowKey); +// if ((Integer.parseInt(rowKey.getRowId()) % 2) == 0){ +// return " "; +// } +// else { +// return "background-color: #eeeeee"; +// } +// } + + private void setNewUser() + { + + NewUser u = new NewUser(); + u = setUserTipo(u); + u.setNumero_mecanografico(""); + u.setResponsavel_loja("n"); + u.setGestor_geral("n"); + switch(u.getTipo().intValue()) + { + case 1: //seg + if(chkSegResp.getSelected() != null) + { + if(chkSegResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + break; + case 2: //rh + if(chkRhResp.getSelected() != null) + { + if(chkRhResp.getSelected().equals(new Boolean(true))) + { + u.setResponsavel_loja("y"); + } + } + break; + case 6: //gestor + if(chkGestaoGeral.getSelected() != null) + { + if(chkGestaoGeral.getSelected().equals(new Boolean(true))) + { + u.setGestor_geral("y"); + } + } + + break; + } + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkAnalisesAcidente_action() { + // TODO: Replace with your code + Integer tipo_utilizador = getSessionBean1().getCurrentUser().getTipo(); + if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP) + { + return "form_dir_siprp"; + } + else if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) + { + return "form_dir_ger_rh"; + } + + return null; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Seccao.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Seccao.java new file mode 100644 index 00000000..f096a6f6 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Seccao.java @@ -0,0 +1,58 @@ +/* + * Seccao.java + * + * Created on December 28, 2007, 11:17 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Seccao { + private Integer id; + private String descricao; + private Integer departamento_id; + private String activo; + + /** Creates a new instance of Seccao */ + public Seccao() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public Integer getDepartamento_id() { + return departamento_id; + } + + public void setDepartamento_id(Integer departamento_id) { + this.departamento_id = departamento_id; + } + + public String getActivo() { + return activo; + } + + public void setActivo(String activo) { + this.activo = activo; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java new file mode 100644 index 00000000..9363c006 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java @@ -0,0 +1,1686 @@ +/* + * UtilizadorFields.java + * + * Created on December 4, 2007, 3:27 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Checkbox; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.HiddenField; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.PasswordField; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextField; +import db.AnalisesDataProvider; +import db.UtilizadoresDataProvider; +import global.Global; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ */ +public class UtilizadorFields extends AbstractPageBean { + // + private int __placeholder; + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser1 = new Hyperlink(); + + public Hyperlink getLnkEditUser1() { + return lnkEditUser1; + } + + public void setLnkEditUser1(Hyperlink h) { + this.lnkEditUser1 = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout1 = new Hyperlink(); + + public Hyperlink getLnkLogout1() { + return lnkLogout1; + } + + public void setLnkLogout1(Hyperlink h) { + this.lnkLogout1 = h; + } + + private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg1() { + return gridMsg1; + } + + public void setGridMsg1(HtmlPanelGrid hpg) { + this.gridMsg1 = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText stCriarEditar = new StaticText(); + + public StaticText getStCriarEditar() { + return stCriarEditar; + } + + public void setStCriarEditar(StaticText st) { + this.stCriarEditar = st; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private Button butApagar = new Button(); + + public Button getButApagar() { + return butApagar; + } + + public void setButApagar(Button b) { + this.butApagar = b; + } + + private Button butGravar = new Button(); + + public Button getButGravar() { + return butGravar; + } + + public void setButGravar(Button b) { + this.butGravar = b; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private DropDown drpEstabelecimentos = new DropDown(); + + public DropDown getDrpEstabelecimentos() { + return drpEstabelecimentos; + } + + public void setDrpEstabelecimentos(DropDown dd) { + this.drpEstabelecimentos = dd; + } + + private StaticText stEstabelecimento = new StaticText(); + + public StaticText getStEstabelecimento() { + return stEstabelecimento; + } + + public void setStEstabelecimento(StaticText st) { + this.stEstabelecimento = st; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private DropDown drpNome = new DropDown(); + + public DropDown getDrpNome() { + return drpNome; + } + + public void setDrpNome(DropDown dd) { + this.drpNome = dd; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private StaticText stNome = new StaticText(); + + public StaticText getStNome() { + return stNome; + } + + public void setStNome(StaticText st) { + this.stNome = st; + } + + private StaticText staticText13 = new StaticText(); + + public StaticText getStaticText13() { + return staticText13; + } + + public void setStaticText13(StaticText st) { + this.staticText13 = st; + } + + private TextField txtLogin = new TextField(); + + public TextField getTxtLogin() { + return txtLogin; + } + + public void setTxtLogin(TextField tf) { + this.txtLogin = tf; + } + + private StaticText staticText14 = new StaticText(); + + public StaticText getStaticText14() { + return staticText14; + } + + public void setStaticText14(StaticText st) { + this.staticText14 = st; + } + + private PasswordField txtPassword = new PasswordField(); + + public PasswordField getTxtPassword() { + return txtPassword; + } + + public void setTxtPassword(PasswordField pf) { + this.txtPassword = pf; + } + + private StaticText staticText15 = new StaticText(); + + public StaticText getStaticText15() { + return staticText15; + } + + public void setStaticText15(StaticText st) { + this.staticText15 = st; + } + + private TextField txtEmail = new TextField(); + + public TextField getTxtEmail() { + return txtEmail; + } + + public void setTxtEmail(TextField tf) { + this.txtEmail = tf; + } + + //
+ boolean isPostback = false; + + private HiddenField hidConfDelUser = new HiddenField(); + + public HiddenField getHidConfDelUser() { + return hidConfDelUser; + } + + public void setHidConfDelUser(HiddenField hf) { + this.hidConfDelUser = hf; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private PasswordField txtConfPassword = new PasswordField(); + + public PasswordField getTxtConfPassword() { + return txtConfPassword; + } + + public void setTxtConfPassword(PasswordField pf) { + this.txtConfPassword = pf; + } + + private StaticText stTipo = new StaticText(); + + public StaticText getStTipo() { + return stTipo; + } + + public void setStTipo(StaticText st) { + this.stTipo = st; + } + + private HtmlPanelGrid gridPanel10 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel10() { + return gridPanel10; + } + + public void setGridPanel10(HtmlPanelGrid hpg) { + this.gridPanel10 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private Checkbox chkActivo = new Checkbox(); + + public Checkbox getChkActivo() { + return chkActivo; + } + + public void setChkActivo(Checkbox c) { + this.chkActivo = c; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private StaticText lblRespLoja = new StaticText(); + + public StaticText getLblRespLoja() { + return lblRespLoja; + } + + public void setLblRespLoja(StaticText st) { + this.lblRespLoja = st; + } + + private Checkbox chkRespLoja = new Checkbox(); + + public Checkbox getChkRespLoja() { + return chkRespLoja; + } + + public void setChkRespLoja(Checkbox c) { + this.chkRespLoja = c; + } + + private StaticText lblGeral = new StaticText(); + + public StaticText getLblGeral() { + return lblGeral; + } + + public void setLblGeral(StaticText st) { + this.lblGeral = st; + } + + private Checkbox chkGeral = new Checkbox(); + + public Checkbox getChkGeral() { + return chkGeral; + } + + public void setChkGeral(Checkbox c) { + this.chkGeral = c; + } + + private HtmlPanelGrid gridPanel11 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel11() { + return gridPanel11; + } + + public void setGridPanel11(HtmlPanelGrid hpg) { + this.gridPanel11 = hpg; + } + + private PanelGroup groupPanel9 = new PanelGroup(); + + public PanelGroup getGroupPanel9() { + return groupPanel9; + } + + public void setGroupPanel9(PanelGroup pg) { + this.groupPanel9 = pg; + } + + private StaticText staticText12 = new StaticText(); + + public StaticText getStaticText12() { + return staticText12; + } + + public void setStaticText12(StaticText st) { + this.staticText12 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText16 = new StaticText(); + + public StaticText getStaticText16() { + return staticText16; + } + + public void setStaticText16(StaticText st) { + this.staticText16 = st; + } + + private StaticText staticText17 = new StaticText(); + + public StaticText getStaticText17() { + return staticText17; + } + + public void setStaticText17(StaticText st) { + this.staticText17 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText18 = new StaticText(); + + public StaticText getStaticText18() { + return staticText18; + } + + public void setStaticText18(StaticText st) { + this.staticText18 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + /** + *

Construct a new Page bean instance.

+ */ + public UtilizadorFields() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("UtilizadorFields Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + if (!getSessionBean1().isLoggedIn()) { + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + } + } + else + { + + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("UtilizadorFields.jsp")) + { + isPostback = false; + } + else + { + isPostback = true; + } + + } + + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + public void prerender() { + if(!isPostback) + { + if(getSessionBean1().getModoEdicaoUtilizador().matches("new")) + { + stCriarEditar.setText("CRIAR"); + butApagar.setRendered(false); + initializeNew(); + } + else if( getSessionBean1().getModoEdicaoUtilizador().matches("edit")) + { + stCriarEditar.setText("EDITAR"); + fillPage(); + } + } + else //postback + { + String del_user = (String)getExternalContext().getRequestParameterMap().get("del_user"); + if(del_user != null) + { + if(del_user.matches("yes")) + { + hidConfDelUser.setValue(""); + try + { + deleteUser(); + getSessionBean1().setMsg("Utilizador eliminado!"); + //return "gestao_utilizadores"; + getSessionBean1().setUserDeleted(true); + try { + getExternalContext().redirect("GestaoUtilizadores.jsp"); + } catch(Exception e) { + } + } + catch(Exception ex) + { + ex.printStackTrace(); + getSessionBean1().setMsg("Erro na eliminação do utilizador!"); + } + } + else if(del_user.matches("no")) + { + hidConfDelUser.setValue(""); + fillPage(); + } + } + + } + + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + return null; + + } + + public void drpTipo_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpNome_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + String nav_from = getSessionBean1().getNavFrom(); + if(nav_from.matches("GestaoUtilizadores")) + { + return "gestao_utilizadores"; + } + else if(nav_from.matches("NovoUtilizador")) + { + return "novo_utilizador"; + } + return null; + } + + public String butApagar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + hidConfDelUser.setValue("apagar"); + return null; + } + + public String butGravar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + if(validationOk( getSessionBean1().getModoEdicaoUtilizador() )) + { + if(getSessionBean1().getModoEdicaoUtilizador().matches("new")) + { + try + { + Utilizador u = addUser(); + addPermissao(u); + getSessionBean1().setMsg("Utilizador criado"); + getSessionBean1().setNewUser(null); + return "gestao_utilizadores"; + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na criação do utilizador!"); + ex.printStackTrace(); + } + } + else if( getSessionBean1().getModoEdicaoUtilizador().matches("edit") ) + { + try + { + updateUser(); + getSessionBean1().setMsg("Utilizador actualizado"); + return "gestao_utilizadores"; + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na actualização do utilizador"); + ex.printStackTrace(); + } + } + } + return null; + } + + private void initializeNew() + { + //drpTipo.setStyleClass("hidden"); + drpEstabelecimentos.setStyleClass("hidden"); + drpNome.setStyleClass("hidden"); + txtNome.setStyleClass("hidden"); + + NewUser u = getSessionBean1().getNewUser(); + stTipo.setText(u.getTipo_descricao()); + stEstabelecimento.setText(u.getEstabelecimento_descricao()); + stNome.setText(Utils.unicodeToHTML(u.getNome())); + + txtLogin.setText(""); + txtPassword.setText(""); + txtConfPassword.setText(""); + txtEmail.setText(""); + + + chkActivo.setSelected(new Boolean(true)); + lblGeral.setRendered(false); + chkGeral.setRendered(false); + lblRespLoja.setRendered(false); + chkRespLoja.setRendered(false); + } + + private void fillPage() + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //Integer permissao = udp.getPermissionCode( getSessionBean1().getCurrentUser().getId() ); + //getSessionBean1().setTiposOptions(adp.getTiposList(permissao)); + getSessionBean1().setTiposOptions(adp.getTiposList()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Utilizador u = getSessionBean1().getEditUser(); + //stTipo.setStyleClass("hidden"); + stEstabelecimento.setStyleClass("hidden"); + stNome.setStyleClass("hidden"); + + System.out.println("ACTIVO = " + u.getActivo()); + if(u.getActivo().matches("y")) + { + chkActivo.setSelected(new Boolean(true)); + } + else + { + chkActivo.setSelected(new Boolean(false)); + } + //drpTipo.setSelected(u.getTipo()); + try + { + stTipo.setText(adp.getTipoDescricao(u.getTipo())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + drpEstabelecimentos.setSelected(u.getEstabelecimento_id()); + + if(u.getTipo().intValue() == 3) //hs + { + drpNome.setStyleClass("hidden"); + txtNome.setText(Utils.unicodeToHTML(u.getNome())); + } + else if(u.getTipo().intValue() == 5) //medico + { + drpNome.setStyleClass("hidden"); + System.out.println("MEDICA : " + Utils.unicodeToHTML(u.getNome())); + txtNome.setText(Utils.unicodeToHTML(u.getNome())); + } + else + { + drpNome.setStyleClass("hidden"); + txtNome.setText(Utils.unicodeToHTML(u.getNome())); + } + + if(u.getTipo().intValue() == 6) // gestor + { + chkGeral.setSelected(new Boolean(false)); + if(u.getGestor_geral().matches("y")) + { + chkGeral.setSelected(new Boolean(true)); + } + } + else + { + lblGeral.setRendered(false); + chkGeral.setRendered(false); + } + + + if(u.getTipo().intValue() == 1 || u.getTipo().intValue() == 2) + { + chkRespLoja.setSelected(new Boolean(false)); + if(u.getResponsavel_loja().matches("y")) + { + chkRespLoja.setSelected(new Boolean(true)); + } + } + else + { + lblRespLoja.setRendered(false); + chkRespLoja.setRendered(false); + } + + txtLogin.setText(u.getLogin()); + //txtPassword.setText(u.getPassword()); + txtEmail.setText(u.getEmail()); + + } + + private boolean validationOk(String modo) + { + if(modo.matches("new")) + { + if(txtLogin.getText() == null) + { + getSessionBean1().setMsg("Tem de indicar o login!"); + return false; + } + else + { + String login = (String) txtLogin.getText(); + if(login.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de indicar o login!"); + return false; + } + else + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + Utilizador u = udp.getUtilizador(login); + if(u.getLogin().equals(login)) + { + getSessionBean1().setMsg("O utilizador " + login + " já existe!"); + return false; + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + if(txtPassword.getText() == null) + { + getSessionBean1().setMsg("Tem de indicar a password!"); + return false; + } + else + { + String password = (String) txtPassword.getText(); + if(password.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de indicar a password!"); + return false; + } + else + { + if(txtConfPassword.getText() == null) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + String conf_password = (String) txtConfPassword.getText(); + if(conf_password.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + if(!password.equals(conf_password)) + { + getSessionBean1().setMsg("A confirmação tem de ser igual à a password!"); + return false; + } + } + } + } // + } + + if(txtEmail.getText() != null) + { + String email = (String) txtEmail.getText(); + if(email.trim().length() > 0) + { + if(! Utils.isValidEmail(email)) + { + getSessionBean1().setMsg("Email inválido!"); + return false; + } + + } + else + { + getSessionBean1().setMsg("Tem de indicar o email!"); + return false; + } + } + else + { + getSessionBean1().setMsg("Tem de indicar o email!"); + return false; + } + + } + else if(modo.matches("edit")) + { + Utilizador u = getSessionBean1().getEditUser(); + +// Integer iTipo = (Integer) drpTipo.getSelected(); +// if(iTipo.intValue() == 0) +// { +// getSessionBean1().setMsg("Falta tipo !"); +// return false; +// } + + int tipo = u.getTipo().intValue(); + + if(tipo != 3) + { + Integer estabelecimento = (Integer) drpEstabelecimentos.getSelected(); + if(estabelecimento.intValue() == -1) + { + getSessionBean1().setMsg("Falta estabelecimento!"); + return false; + } + } + +// if(tipo == 3 || tipo == 5) +// { +// Integer nome = (Integer) drpNome.getSelected(); +// if(nome.intValue() == 0) +// { +// getSessionBean1().setMsg("Falta nome !"); +// return false; +// } +// } +// else +// { + if(txtNome.getText() == null) + { + getSessionBean1().setMsg("Falta nome!"); + + return false; + } + else + { + String nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + getSessionBean1().setMsg("Falta nome!"); + return false; + } + } +// } + + + if(txtLogin.getText() == null) + { + getSessionBean1().setMsg("Tem de indicar o login!"); + return false; + } + else + { + String login = (String) txtLogin.getText(); + if(login.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de indicar o login!"); + return false; + } + else + { + if(!login.equals(u.getLogin())) + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + Utilizador ut = udp.getUtilizador(login); + if(ut.getLogin().equals(login)) + { + getSessionBean1().setMsg("O utilizador " + login + " já existe!"); + return false; + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + } + } +// if(txtPassword.getText() == null) +// { +// getSessionBean1().setMsg("Falta password!"); +// return false; +// } +// else + if(txtPassword.getText() != null) + { + String password = (String) txtPassword.getText(); + if(password.trim().length() > 0) + { + if(! password.equals(u.getPassword())) + { + if(txtConfPassword.getText() == null) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + String conf_password = (String) txtConfPassword.getText(); + if(conf_password.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + if(!password.equals(conf_password)) + { + getSessionBean1().setMsg("A confirmação tem de ser igual à password!"); + return false; + } + } + } + } + } + else + { + if(txtConfPassword.getText() != null) + { + String conf = (String) txtConfPassword.getText(); + if(conf.trim().length() > 0) + { + getSessionBean1().setMsg("Falta password!"); + return false; + } + } + } + } + else + { + if(txtConfPassword.getText() != null) + { + String conf = (String) txtConfPassword.getText(); + if(conf.trim().length() > 0) + { + getSessionBean1().setMsg("Falta password!"); + return false; + } + } + } + + if(txtEmail.getText() != null) + { + String email = (String) txtEmail.getText(); + if(email.trim().length() > 0) + { + if(! Utils.isValidEmail(email)) + { + getSessionBean1().setMsg("Email inválido!"); + return false; + } + + } + } + else + { + getSessionBean1().setMsg("Tem de indicar o email!"); + return false; + } + + } + return true; + } + + private Utilizador addUser() throws Exception + { + Utilizador u = fillUser(); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + Integer id = udp.createNewUtilizador(u); + u.setId(id); + return u; + } + + private void addPermissao(Utilizador u) throws Exception + { + Permissao p = new Permissao(); + p.setUser_id(u.getId()); + p.setCodigo_permissao(u.getTipo()); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.createPermissao(p); + } + + private void updateUser() throws Exception + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + //Utilizador u = fillUser(); + Utilizador u = getSessionBean1().getEditUser(); + + + //u.setTipo((Integer) drpTipo.getSelected()); + u.setEstabelecimento_id( (Integer) drpEstabelecimentos.getSelected() ); + + int tipo = u.getTipo().intValue(); +// if(tipo == 3) +// { +// u.setFuncionario_hst_id((Integer) drpNome.getSelected()); +// u.setNome( adp.getTecnicoSaudeNome( u.getFuncionario_hst_id() ) ); +// } +// else if(tipo == 5) +// { +// u.setMedico_id( (Integer) drpNome.getSelected() ); +// u.setNome( adp.getMedicoNome(u.getMedico_id()) ); +// } + u.setActivo("n"); + if(chkActivo.getSelected() != null) + { + if(chkActivo.getSelected().equals(new Boolean(true))) + { + u.setActivo("y"); + } + } + u.setNome((String) txtNome.getText()); + u.setLogin((String) txtLogin.getText()); + if(txtPassword.getText() != null) + { + String password = (String) txtPassword.getText(); + if(password.trim().length() > 0) + { + u.setPassword(password); + } + } + + u.setEmail((String) txtEmail.getText()); + + u.setGestor_geral("n"); + try + { + if(chkGeral.getSelected() != null) + { + if(chkGeral.getSelected().equals(new Boolean(true)) ) + { + u.setGestor_geral("y"); + } + } + } + catch(Exception ex){} + + u.setResponsavel_loja("n"); + try + { + if(chkRespLoja.getSelected() != null) + { + if(chkRespLoja.getSelected().equals(new Boolean(true)) ) + { + u.setResponsavel_loja("y"); + } + } + } + catch(Exception ex){} + u.setPrimeiro_login("n"); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.updateUtilizador(u); + } + + + private Utilizador fillUser() + { + NewUser nu = getSessionBean1().getNewUser(); + Utilizador u = new Utilizador(); + u.setActivo("n"); + if(chkActivo.getSelected() != null) + { + if(chkActivo.getSelected().equals(new Boolean(true))) + { + u.setActivo("y"); + } + } + u.setAdministrador("n"); + u.setTipo(nu.getTipo()); + u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); + u.setEstabelecimento_id( nu.getEstabelecimento() ); + u.setNome(Utils.unicodeToHTML(nu.getNome())); + u.setLogin( (String) txtLogin.getText() ); + u.setPassword( (String) txtPassword.getText() ); + java.util.Date today = + new java.util.Date(); + java.sql.Date sqlToday = + new java.sql.Date(today.getTime()); + u.setData_password(sqlToday); + u.setEmail(""); + u.setNumero_mecanografico(nu.getNumero_mecanografico()); + if(txtEmail.getText() != null) + { + u.setEmail( (String) txtEmail.getText() ); + } + + Integer tipo = (Integer) nu.getTipo(); + + u.setNumero_cedula(""); + u.setCap(""); + if(tipo.intValue() == 3 || tipo.intValue() == 5) + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + if(tipo.intValue() == 3) + { + try + { + //Integer tecnico_id = (Integer) drpNome.getSelected(); + //u.setFuncionario_hst_id(tecnico_id); + //u.setNome( adp.getTecnicoSaudeNome(tecnico_id) ); + u.setFuncionario_hst_id(nu.getFuncionario_hst_id()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + u.setCap( nu.getCap()); + } + else // medico + { + try + { + //Integer medico_id = (Integer) drpNome.getSelected(); + //u.setMedico_id(medico_id); + //u.setNome( adp.getMedicoNome(medico_id) ); + u.setMedico_id(nu.getMedico_id()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + //u.setNumero_cedula( (String) stCedula.getText()); + u.setNumero_cedula(nu.getNumero_cedula()); + } + } +// else +// { +// u.setNome( (String) txtNome.getText() ); +// } + + u.setResponsavel_loja(nu.getResponsavel_loja()); + if(nu.getGestor_geral() == null) + { + u.setGestor_geral("n"); + } + else + { + u.setGestor_geral(nu.getGestor_geral()); + } + + +// u.setResponsavel_loja("n"); +// if(chkResponsavelLoja.getSelected() != null) +// { +// if(chkResponsavelLoja.getSelected().equals(new Boolean(true))) +// { +// u.setResponsavel_loja("y"); +// } +// } + return u; + } + + private void deleteUser() throws Exception + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.deleteUser(getSessionBean1().getEditUser().getId()); + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkAnalisesAcidente_action() { + // TODO: Replace with your code + Integer tipo_utilizador = getSessionBean1().getCurrentUser().getTipo(); + if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP) + { + return "form_dir_siprp"; + } + else if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) + { + return "form_dir_ger_rh"; + } + + return null; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/EstadosCorrecaoDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/EstadosCorrecaoDataProvider.java new file mode 100644 index 00000000..4a1ac627 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/EstadosCorrecaoDataProvider.java @@ -0,0 +1,24 @@ +/* + * EstadosCorrecaoDataProvider.java + * + * Created on November 29, 2007, 9:50 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package db; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class EstadosCorrecaoDataProvider extends ObjectListDataProvider { + + /** Creates a new instance of EstadosCorrecaoDataProvider */ + public EstadosCorrecaoDataProvider() { + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresActivosListDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresActivosListDataProvider.java new file mode 100644 index 00000000..62c8f48a --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresActivosListDataProvider.java @@ -0,0 +1,24 @@ +/* + * UtilizadoresListDataProvider.java + * + * Created on November 30, 2007, 2:51 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package db; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class UtilizadoresActivosListDataProvider extends ObjectListDataProvider { + + /** Creates a new instance of UtilizadoresListDataProvider */ + public UtilizadoresActivosListDataProvider() { + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresInactivosListDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresInactivosListDataProvider.java new file mode 100644 index 00000000..b0c374ff --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresInactivosListDataProvider.java @@ -0,0 +1,24 @@ +/* + * UtilizadoresInactivosListDataProvider.java + * + * Created on November 30, 2007, 4:48 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package db; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class UtilizadoresInactivosListDataProvider extends ObjectListDataProvider { + + /** Creates a new instance of UtilizadoresInactivosListDataProvider */ + public UtilizadoresInactivosListDataProvider() { + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java b/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java new file mode 100755 index 00000000..77dac1ad --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/global/Global.java @@ -0,0 +1,97 @@ +/* + * Global.java + * + * Created on November 23, 2007, 10:08 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package global; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * + * @author lluis2 + */ +public class Global { + public final static int ESTADO_SEG = 1; + public final static int ESTADO_RH1 = 2; + public final static int ESTADO_HS = 3; + public final static int ESTADO_RH2 = 4; + //public final static int ESTADO_MEDICINA = 5; + public final static int ESTADO_CONSOLIDACAO = 5; + //public final static int ESTADO_ASSINATURAS = 7; + public final static int ESTADO_ASSINATURA_SEG = 6; + public final static int ESTADO_ASSINATURA_RH = 7; + //public final static int ESTADO_IMPRESSAO = 8; + public final static int ESTADO_FECHAR = 8; + public final static int ESTADO_CONCLUIDO = 9; + + + public final static int ESTADO_ASSINATURA_1 = 1; + public final static int ESTADO_ASSINATURA_2 = 2; + public final static int ESTADO_ASSINATURA_3 = 3; + + public final static int TIPO_UTILIZADOR_SEGURANCA = 1; + public final static int TIPO_UTILIZADOR_RH = 2; + public final static int TIPO_UTILIZADOR_HS = 3; + public final static int TIPO_UTILIZADOR_MEDICO = 5; + public final static int TIPO_UTILIZADOR_GESTOR = 6; + public final static int TIPO_UTILIZADOR_DIRECTOR_GERAL_RH = 7; + public final static int TIPO_UTILIZADOR_DIRECTOR_SIPRP = 8; + + public final static int AUCHAN = 32; + + + public final static String SERVIDOR_SMTP = "smtp.netcabo.pt"; + public final static String SERVIDOR_SMTP_PASSWORD = "EVOLUTE"; + public final static String ENDERECO_ENVIO = "acidentes.auchan@siprp.pt"; + + public final static String IMAGE_FOLDER = "/home/siprp/imagens_acidentes"; + //public final static String IMAGE_FOLDER = "/home/lluis/imagens_acidentes"; + public final static String RESOURCES_IMAGE_FOLDER = "/resources/images"; + /** Creates a new instance of Global */ + public Global() { + } + + public void copyImage(File fSource, File fDest) + { + try + { + InputStream in = new FileInputStream(fSource); + OutputStream out = new FileOutputStream(fDest); + + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + public void deleteFolderFiles(File folder) + { + File files[] = folder.listFiles(); + for(int i=0;i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/FormDirGerRh.jsp b/trunk/AnaliseAcidentesTrabalho/web/FormDirGerRh.jsp new file mode 100644 index 00000000..61dabaed --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/FormDirGerRh.jsp @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp b/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp new file mode 100755 index 00000000..1674cba2 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/FormGestor.jsp b/trunk/AnaliseAcidentesTrabalho/web/FormGestor.jsp new file mode 100644 index 00000000..071c8e14 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/FormGestor.jsp @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/GestaoUtilizadores.jsp b/trunk/AnaliseAcidentesTrabalho/web/GestaoUtilizadores.jsp new file mode 100644 index 00000000..6a08d215 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/GestaoUtilizadores.jsp @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/NovoUtilizador.jsp b/trunk/AnaliseAcidentesTrabalho/web/NovoUtilizador.jsp new file mode 100644 index 00000000..ec813f01 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/NovoUtilizador.jsp @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/UtilizadorFields.jsp b/trunk/AnaliseAcidentesTrabalho/web/UtilizadorFields.jsp new file mode 100644 index 00000000..df4eb2b8 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/UtilizadorFields.jsp @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/1 b/trunk/AnaliseAcidentesTrabalho/web/resources/1 new file mode 100644 index 00000000..4720ac5e Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/1 differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo.gif new file mode 100644 index 00000000..8fa06785 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo_mini.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo_mini.gif new file mode 100644 index 00000000..c77c826c Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/auchan_logo_mini.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/ma1.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/ma1.gif new file mode 100755 index 00000000..6141cfcd Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/ma1.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca1.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca1.gif new file mode 100755 index 00000000..76ca9ac0 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca1.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca4.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca4.gif new file mode 100755 index 00000000..baf6f2bd Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ca4.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ext4.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ext4.gif new file mode 100755 index 00000000..fa96b7d5 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ext4.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/fle1.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/fle1.gif new file mode 100755 index 00000000..7ea7b35e Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/fle1.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma1.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma1.gif new file mode 100755 index 00000000..6141cfcd Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma1.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma4.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma4.gif new file mode 100755 index 00000000..9deb31a7 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma4.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma7.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma7.gif new file mode 100755 index 00000000..98aa5304 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma7.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma9.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma9.gif new file mode 100755 index 00000000..ced4fc27 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/ma9.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot1.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot1.gif new file mode 100755 index 00000000..938aa4f5 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot1.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot2.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot2.gif new file mode 100755 index 00000000..eb785c9c Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/medico/rot2.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo.gif new file mode 100644 index 00000000..9c64e995 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo.gif differ diff --git a/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo_mini.gif b/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo_mini.gif new file mode 100644 index 00000000..f24aa23f Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/resources/images/siprp_logo_mini.gif differ