/*
 * FormSeguranca.java
 *
 * Created on September 19, 2007, 1:10 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.AnalisesActualDataProvider;
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;

/**
 * <p>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.</p>
 */
public class FormSeguranca extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
    private int __placeholder;
    
    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    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 gridBase = new HtmlPanelGrid();

    public HtmlPanelGrid getGridBase() {
        return gridBase;
    }

    public void setGridBase(HtmlPanelGrid hpg) {
        this.gridBase = hpg;
    }

    private HtmlPanelGrid gridLayout = new HtmlPanelGrid();

    public HtmlPanelGrid getGridLayout() {
        return gridLayout;
    }

    public void setGridLayout(HtmlPanelGrid hpg) {
        this.gridLayout = hpg;
    }

    private HtmlPanelGrid gridLayoutTop = new HtmlPanelGrid();

    public HtmlPanelGrid getGridLayoutTop() {
        return gridLayoutTop;
    }

    public void setGridLayoutTop(HtmlPanelGrid hpg) {
        this.gridLayoutTop = hpg;
    }

    private HtmlPanelGrid gridActual = new HtmlPanelGrid();

    public HtmlPanelGrid getGridActual() {
        return gridActual;
    }

    public void setGridActual(HtmlPanelGrid hpg) {
        this.gridActual = hpg;
    }

    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }

    private StaticText staticText1 = new StaticText();

    public StaticText getStaticText1() {
        return staticText1;
    }

    public void setStaticText1(StaticText st) {
        this.staticText1 = st;
    }

    private HtmlPanelGrid gridSeguimento = new HtmlPanelGrid();

    public HtmlPanelGrid getGridSeguimento() {
        return gridSeguimento;
    }

    public void setGridSeguimento(HtmlPanelGrid hpg) {
        this.gridSeguimento = 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 gridConcluidos = new HtmlPanelGrid();

    public HtmlPanelGrid getGridConcluidos() {
        return gridConcluidos;
    }

    public void setGridConcluidos(HtmlPanelGrid hpg) {
        this.gridConcluidos = hpg;
    }

    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 Link link2 = new Link();

    public Link getLink2() {
        return link2;
    }

    public void setLink2(Link l) {
        this.link2 = l;
    }

    private Button butNovaAnalise = new Button();

    public Button getButNovaAnalise() {
        return butNovaAnalise;
    }

    public void setButNovaAnalise(Button b) {
        this.butNovaAnalise = b;
    }

    private StaticText staticText4 = new StaticText();

    public StaticText getStaticText4() {
        return staticText4;
    }

    public void setStaticText4(StaticText st) {
        this.staticText4 = st;
    }

    private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel4() {
        return gridPanel4;
    }

    public void setGridPanel4(HtmlPanelGrid hpg) {
        this.gridPanel4 = 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 TableColumn tableColumn2 = new TableColumn();

    public TableColumn getTableColumn2() {
        return tableColumn2;
    }

    public void setTableColumn2(TableColumn tc) {
        this.tableColumn2 = tc;
    }

    private TableColumn tableColumn3 = new TableColumn();

    public TableColumn getTableColumn3() {
        return tableColumn3;
    }

    public void setTableColumn3(TableColumn tc) {
        this.tableColumn3 = tc;
    }

    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 tableColumn4 = new TableColumn();

    public TableColumn getTableColumn4() {
        return tableColumn4;
    }

    public void setTableColumn4(TableColumn tc) {
        this.tableColumn4 = tc;
    }

    private TableColumn tableColumn5 = new TableColumn();

    public TableColumn getTableColumn5() {
        return tableColumn5;
    }

    public void setTableColumn5(TableColumn tc) {
        this.tableColumn5 = tc;
    }

    private TableColumn tableColumn6 = new TableColumn();

    public TableColumn getTableColumn6() {
        return tableColumn6;
    }

    public void setTableColumn6(TableColumn tc) {
        this.tableColumn6 = tc;
    }

    private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel6() {
        return gridPanel6;
    }

    public void setGridPanel6(HtmlPanelGrid hpg) {
        this.gridPanel6 = hpg;
    }

    private PanelGroup groupPanel1 = new PanelGroup();

    public PanelGroup getGroupPanel1() {
        return groupPanel1;
    }

    public void setGroupPanel1(PanelGroup pg) {
        this.groupPanel1 = pg;
    }

    private StaticText staticText11 = new StaticText();

    public StaticText getStaticText11() {
        return staticText11;
    }

    public void setStaticText11(StaticText st) {
        this.staticText11 = st;
    }

    private DropDown drpAno = new DropDown();

    public DropDown getDrpAno() {
        return drpAno;
    }

    public void setDrpAno(DropDown dd) {
        this.drpAno = dd;
    }

    private PanelGroup groupPanel2 = new PanelGroup();

    public PanelGroup getGroupPanel2() {
        return groupPanel2;
    }

    public void setGroupPanel2(PanelGroup pg) {
        this.groupPanel2 = 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 groupPanel3 = new PanelGroup();

    public PanelGroup getGroupPanel3() {
        return groupPanel3;
    }

    public void setGroupPanel3(PanelGroup pg) {
        this.groupPanel3 = 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 groupPanel4 = new PanelGroup();

    public PanelGroup getGroupPanel4() {
        return groupPanel4;
    }

    public void setGroupPanel4(PanelGroup pg) {
        this.groupPanel4 = pg;
    }

    private StaticText staticText14 = new StaticText();

    public StaticText getStaticText14() {
        return staticText14;
    }

    public void setStaticText14(StaticText st) {
        this.staticText14 = 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 gridPanel7 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel7() {
        return gridPanel7;
    }

    public void setGridPanel7(HtmlPanelGrid hpg) {
        this.gridPanel7 = 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 tableColumn7 = new TableColumn();

    public TableColumn getTableColumn7() {
        return tableColumn7;
    }

    public void setTableColumn7(TableColumn tc) {
        this.tableColumn7 = tc;
    }

    private TableColumn tableColumn8 = new TableColumn();

    public TableColumn getTableColumn8() {
        return tableColumn8;
    }

    public void setTableColumn8(TableColumn tc) {
        this.tableColumn8 = tc;
    }

    private TableColumn tableColumn9 = new TableColumn();

    public TableColumn getTableColumn9() {
        return tableColumn9;
    }

    public void setTableColumn9(TableColumn tc) {
        this.tableColumn9 = tc;
    }

    private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel8() {
        return gridPanel8;
    }

    public void setGridPanel8(HtmlPanelGrid hpg) {
        this.gridPanel8 = hpg;
    }

    private PanelGroup groupPanel5 = new PanelGroup();

    public PanelGroup getGroupPanel5() {
        return groupPanel5;
    }

    public void setGroupPanel5(PanelGroup pg) {
        this.groupPanel5 = 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 groupPanel6 = new PanelGroup();

    public PanelGroup getGroupPanel6() {
        return groupPanel6;
    }

    public void setGroupPanel6(PanelGroup pg) {
        this.groupPanel6 = pg;
    }

    private StaticText lblUser = new StaticText();

    public StaticText getLblUser() {
        return lblUser;
    }

    public void setLblUser(StaticText st) {
        this.lblUser = st;
    }

    private StaticText staticText18 = new StaticText();

    public StaticText getStaticText18() {
        return staticText18;
    }

    public void setStaticText18(StaticText st) {
        this.staticText18 = st;
    }

    private Hyperlink lnkEditUser = new Hyperlink();

    public Hyperlink getLnkEditUser() {
        return lnkEditUser;
    }

    public void setLnkEditUser(Hyperlink h) {
        this.lnkEditUser = h;
    }

    private StaticText staticText19 = new StaticText();

    public StaticText getStaticText19() {
        return staticText19;
    }

    public void setStaticText19(StaticText st) {
        this.staticText19 = st;
    }

    private Hyperlink lnkLogout = new Hyperlink();

    public Hyperlink getLnkLogout() {
        return lnkLogout;
    }

    public void setLnkLogout(Hyperlink h) {
        this.lnkLogout = h;
    }

    private Hyperlink lnkDataAcidente = new Hyperlink();

    public Hyperlink getLnkDataAcidente() {
        return lnkDataAcidente;
    }

    public void setLnkDataAcidente(Hyperlink h) {
        this.lnkDataAcidente = h;
    }

    private Hyperlink lnkNr = new Hyperlink();

    public Hyperlink getLnkNr() {
        return lnkNr;
    }

    public void setLnkNr(Hyperlink h) {
        this.lnkNr = h;
    }

    private Hyperlink lnkNomeAcidentado = new Hyperlink();

    public Hyperlink getLnkNomeAcidentado() {
        return lnkNomeAcidentado;
    }

    public void setLnkNomeAcidentado(Hyperlink h) {
        this.lnkNomeAcidentado = h;
    }

    private Hyperlink lnkDataAcidenteSeg = new Hyperlink();

    public Hyperlink getLnkDataAcidenteSeg() {
        return lnkDataAcidenteSeg;
    }

    public void setLnkDataAcidenteSeg(Hyperlink h) {
        this.lnkDataAcidenteSeg = h;
    }

    private Hyperlink lnkNrSeg = new Hyperlink();

    public Hyperlink getLnkNrSeg() {
        return lnkNrSeg;
    }

    public void setLnkNrSeg(Hyperlink h) {
        this.lnkNrSeg = h;
    }

    private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink();

    public Hyperlink getLnkNomeAcidentadoSeg() {
        return lnkNomeAcidentadoSeg;
    }

    public void setLnkNomeAcidentadoSeg(Hyperlink h) {
        this.lnkNomeAcidentadoSeg = h;
    }

    private Hyperlink lnkDataConcluida = new Hyperlink();

    public Hyperlink getLnkDataConcluida() {
        return lnkDataConcluida;
    }

    public void setLnkDataConcluida(Hyperlink h) {
        this.lnkDataConcluida = h;
    }

    private Hyperlink lnkNrConcluida = new Hyperlink();

    public Hyperlink getLnkNrConcluida() {
        return lnkNrConcluida;
    }

    public void setLnkNrConcluida(Hyperlink h) {
        this.lnkNrConcluida = h;
    }

    private Hyperlink lnkNomeConcluida = new Hyperlink();

    public Hyperlink getLnkNomeConcluida() {
        return lnkNomeConcluida;
    }

    public void setLnkNomeConcluida(Hyperlink h) {
        this.lnkNomeConcluida = h;
    }

    private StaticText txtSearchMsg = new StaticText();

    public StaticText getTxtSearchMsg() {
        return txtSearchMsg;
    }

    public void setTxtSearchMsg(StaticText st) {
        this.txtSearchMsg = st;
    }

    private TableColumn tableColumn10 = new TableColumn();

    public TableColumn getTableColumn10() {
        return tableColumn10;
    }

    public void setTableColumn10(TableColumn tc) {
        this.tableColumn10 = tc;
    }

    private TableColumn tableColumn11 = new TableColumn();

    public TableColumn getTableColumn11() {
        return tableColumn11;
    }

    public void setTableColumn11(TableColumn tc) {
        this.tableColumn11 = tc;
    }

    private Hyperlink lnkFase = new Hyperlink();

    public Hyperlink getLnkFase() {
        return lnkFase;
    }

    public void setLnkFase(Hyperlink h) {
        this.lnkFase = h;
    }

    private Hyperlink lnkFaseSeg = new Hyperlink();

    public Hyperlink getLnkFaseSeg() {
        return lnkFaseSeg;
    }

    public void setLnkFaseSeg(Hyperlink h) {
        this.lnkFaseSeg = h;
    }

    private TableColumn tableColumn12 = new TableColumn();

    public TableColumn getTableColumn12() {
        return tableColumn12;
    }

    public void setTableColumn12(TableColumn tc) {
        this.tableColumn12 = tc;
    }

    private TableColumn tableColumn13 = new TableColumn();

    public TableColumn getTableColumn13() {
        return tableColumn13;
    }

    public void setTableColumn13(TableColumn tc) {
        this.tableColumn13 = tc;
    }

    private TableColumn tableColumn14 = new TableColumn();

    public TableColumn getTableColumn14() {
        return tableColumn14;
    }

    public void setTableColumn14(TableColumn tc) {
        this.tableColumn14 = tc;
    }

    private TableColumn tableColumn15 = new TableColumn();

    public TableColumn getTableColumn15() {
        return tableColumn15;
    }

    public void setTableColumn15(TableColumn tc) {
        this.tableColumn15 = tc;
    }

    private Hyperlink lnkPor = new Hyperlink();

    public Hyperlink getLnkPor() {
        return lnkPor;
    }

    public void setLnkPor(Hyperlink h) {
        this.lnkPor = h;
    }

    private Hyperlink lnkPorSeg = new Hyperlink();

    public Hyperlink getLnkPorSeg() {
        return lnkPorSeg;
    }

    public void setLnkPorSeg(Hyperlink h) {
        this.lnkPorSeg = h;
    }

    private Hyperlink lnkPorConcluida = new Hyperlink();

    public Hyperlink getLnkPorConcluida() {
        return lnkPorConcluida;
    }

    public void setLnkPorConcluida(Hyperlink h) {
        this.lnkPorConcluida = h;
    }

    private Hyperlink lnkEstabConcluida = new Hyperlink();

    public Hyperlink getLnkEstabConcluida() {
        return lnkEstabConcluida;
    }

    public void setLnkEstabConcluida(Hyperlink h) {
        this.lnkEstabConcluida = h;
    }

    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 TextField txtPor = new TextField();

    public TextField getTxtPor() {
        return txtPor;
    }

    public void setTxtPor(TextField tf) {
        this.txtPor = tf;
    }

    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 staticText6 = new StaticText();

    public StaticText getStaticText6() {
        return staticText6;
    }

    public void setStaticText6(StaticText st) {
        this.staticText6 = st;
    }

    private ImageComponent image3 = new ImageComponent();

    public ImageComponent getImage3() {
        return image3;
    }

    public void setImage3(ImageComponent ic) {
        this.image3 = ic;
    }

    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 Hyperlink lnkNewUser1 = new Hyperlink();

    public Hyperlink getLnkNewUser1() {
        return lnkNewUser1;
    }

    public void setLnkNewUser1(Hyperlink h) {
        this.lnkNewUser1 = h;
    }

    private StaticText staticText9 = new StaticText();

    public StaticText getStaticText9() {
        return staticText9;
    }

    public void setStaticText9(StaticText st) {
        this.staticText9 = st;
    }

    private StaticText staticText10 = new StaticText();

    public StaticText getStaticText10() {
        return staticText10;
    }

    public void setStaticText10(StaticText st) {
        this.staticText10 = st;
    }

    private Hyperlink lnkAnalisesAcidente = new Hyperlink();

    public Hyperlink getLnkAnalisesAcidente() {
        return lnkAnalisesAcidente;
    }

    public void setLnkAnalisesAcidente(Hyperlink h) {
        this.lnkAnalisesAcidente = h;
    }
    
    // </editor-fold>
    
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public FormSeguranca() {
    }
    
    /**
     * <p>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.</p>
     *
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    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
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("FormSeguranca Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // 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 . . .              
	    }
	}	        
    }
    
    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> 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.</p>
     */
    public void preprocess() {

    }
    
    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> 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.</p>
     */
    public void prerender() {
        lblUser.setText( getSessionBean1().getCurrentUser().getLogin() );
        String responsavel_loja = getSessionBean1().getCurrentUser().getResponsavel_loja();
       AnalisesDataProvider adp = new AnalisesDataProvider();
       try
       {
            //lblActivos.setRendered(true);
            table1.setRendered(true);                                      

            //ArrayList actuaisList = adp.getAnalisesActuaisList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), new Integer(1));
            ArrayList actuaisList = adp.getAnalisesActuaisSegList( getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja );            
            getSessionBean1().getAnalisesActualDataProvider().setList(actuaisList);
       }
       catch(Exception ex)
       {
           //lblActivos.setRendered(false);
           table1.setRendered(false);                   
           //ex.printStackTrace();
       }        
       
       try
       {
            //lblActivos.setRendered(true);
            table2.setRendered(true);                                      

            ArrayList seguimentoList = adp.getAnalisesSeguimentoSegList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja);
            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("FormSeguranca.jsp"))
       {
           
           try
           {
                //lblActivos.setRendered(true);
                table3.setRendered(true);                                      

                ArrayList concluidasList = adp.getAnalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id());
                getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList);
           }
           catch(Exception ex)
           {
               //lblActivos.setRendered(false);
               table3.setRendered(false);                   
               //ex.printStackTrace();
           }            
            fillAnoDropDown();       
       }
       
    }
    
    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    public void destroy() {
    }
    
    
//    private void fillDateDropDowns()
//    {
//        fillAnoDropDown();
//        //fillMesDropDown();        
//        //fillDiaDropDown();        
//    }
    
    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()
    {
        int ano = ( (Integer)drpAno.getSelected() ).intValue();
        int mes = ( (Integer)drpMes.getSelected() ).intValue();
        int dias = 0;
        switch (mes) {
            case 1:  dias=31; break;
            case 2:  
                GregorianCalendar cal = new GregorianCalendar();
                if(cal.isLeapYear(ano))
                {
                    dias = 29;
                }    
                else
                {
                    dias = 28;
                }
                break;
            case 3:  dias=31; break;
            case 4:  dias=30; break;
            case 5:  dias=31; break;
            case 6:  dias=30; break;
            case 7:  dias=31; break;
            case 8:  dias=31; break;
            case 9:  dias=30; break;
            case 10: dias=31; break;
            case 11: dias=30; break;
            case 12: dias=31; break;
            default: System.out.println("Invalid month.");break;
        }
        
        ArrayList diasList = new ArrayList();
        for(int dia=1; dia<dias+1; dia++)
        {
            diasList.add(new Integer(dia));
        }
        com.sun.rave.web.ui.model.Option[] diaOptions = new com.sun.rave.web.ui.model.Option[diasList.size()+1];        
        ListIterator iter = diasList.listIterator();
        diaOptions[0] = new Option("", "");                
        int j = 1;
        while(iter.hasNext())
        {
            Integer dia = (Integer) iter.next();
            
            diaOptions[j] = new Option(dia, dia.toString());
            j++;
        }
        getSessionBean1().setDiaOptions(diaOptions);    
        Calendar cal = new GregorianCalendar();
        int day = cal.get(Calendar.DAY_OF_MONTH); 
        drpDia.setSelected( new Integer(0) );                        
    }    
    
    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1)getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1)getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1)getBean("ApplicationBean1");
    }

    public String lnkLogout_action() {
        // TODO: Replace with your code
	    // Invalidate the current session
        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 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 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(getSessionBean1().getCurrentUser().getEstabelecimento_id(), 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&atilde;o foram encontrados registos para a sua pesquisa !");
            //ex.printStackTrace();
        }

        return null;
    }    
    
    public void drpDia_processValueChange(ValueChangeEvent vce) {
        // TODO: Replace with your code
        
    }    
    
//    private String getPageFrom(String referer)
//    {
//        String pageFrom = referer.substring(referer.lastIndexOf("/")+1);
//        return pageFrom;
//    }

    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.
        
        getSessionBean1().setNavFrom("FormSeguranca");
        getSessionBean1().setCurrentAnalise(null);
        return "analise_acidente";
    }

    public String lnkDataAcidente_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableActivosRowData();
        getSessionBean1().setCurrentAnalise(a);
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "analise_acidente";
    }

    public String lnkNr_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableActivosRowData();
        getSessionBean1().setCurrentAnalise(a);  
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "analise_acidente";
    }

    public String lnkNomeAcidentado_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableActivosRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "analise_acidente";
    }
    
    private AnaliseAcidente getTableActivosRowData()
    {
        RowKey rk = tableRowGroup1.getRowKey();
        int k = Integer.parseInt(rk.getRowId());        
        AnalisesActualDataProvider provider = (AnalisesActualDataProvider) tableRowGroup1.getSourceData();
        ArrayList list = (ArrayList) provider.getList();
        AnaliseAcidente a = (AnaliseAcidente)list.get(k);
        return a;
    }

    public String lnkDataAcidenteSeg_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableSeguimentoRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";

    }

    public String lnkNrSeg_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableSeguimentoRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkNomeAcidentadoSeg_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableSeguimentoRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        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;
    }    
    
    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 lnkEditUser_action() {
        // TODO: Replace with your code
        getSessionBean1().setNavFrom("FormSeguranca");
        getSessionBean1().setModoEdicaoUtilizador("edit");
        return "user";        
    }

    public String lnkDataConcluida_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableConcluidasRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkNrConcluida_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableConcluidasRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkNomeConcluida_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableConcluidasRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkFase_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableActivosRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "analise_acidente";        
    }

    public String lnkFaseSeg_action() {
        // TODO: Replace with your code
        AnaliseAcidente a = getTableSeguimentoRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";        
    }

    public String lnkPor_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableActivosRowData();
        getSessionBean1().setCurrentAnalise(a);
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "analise_acidente";    }

    public String lnkPorSeg_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableSeguimentoRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";        
    }

    public String lnkPorConcluida_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableConcluidasRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkEstabConcluida_action() {
        // TODO: Replace with your code
        
        AnaliseAcidente a = getTableConcluidasRowData();
        getSessionBean1().setCurrentAnalise(a);      
        getSessionBean1().setNavFrom("FormSeguranca");        
        return "view_analise";
    }

    public String lnkNewUser_action() {
        // TODO: Replace with your code
        
        return null;
    }
}

