|
|
/*
|
|
|
* PlanoActuacao.java
|
|
|
*
|
|
|
* Created on Aug 26, 2008, 3:10:59 PM
|
|
|
*/
|
|
|
|
|
|
package planosactuacao;
|
|
|
|
|
|
import com.sun.rave.web.ui.appbase.AbstractPageBean;
|
|
|
import com.sun.webui.jsf.component.Anchor;
|
|
|
import com.sun.webui.jsf.component.Button;
|
|
|
import com.sun.webui.jsf.component.Calendar;
|
|
|
import com.sun.webui.jsf.component.Checkbox;
|
|
|
import com.sun.webui.jsf.component.PanelGroup;
|
|
|
import com.sun.webui.jsf.component.StaticText;
|
|
|
import com.sun.webui.jsf.component.TextArea;
|
|
|
import com.sun.webui.jsf.component.TextField;
|
|
|
|
|
|
import db.entidades.Area;
|
|
|
import db.entidades.Medida;
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
import db.entidades.PostoTrabalho;
|
|
|
import db.entidades.Risco;
|
|
|
import db.entidades.Utilizador;
|
|
|
import db.entidades.Valor;
|
|
|
import db.providers.PlanosDataProvider;
|
|
|
import db.providers.UtilizadoresDataProvider;
|
|
|
import global.Global;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.ListIterator;
|
|
|
import java.util.Vector;
|
|
|
import javax.el.MethodExpression;
|
|
|
import javax.faces.FacesException;
|
|
|
import javax.faces.component.html.HtmlInputHidden;
|
|
|
import javax.faces.component.html.HtmlPanelGrid;
|
|
|
import javax.faces.context.FacesContext;
|
|
|
import javax.faces.event.ActionEvent;
|
|
|
import javax.faces.event.MethodExpressionActionListener;
|
|
|
import javax.faces.event.ValueChangeEvent;
|
|
|
import mail.Mail;
|
|
|
import pagination.Pagina;
|
|
|
import pagination.Pagination;
|
|
|
import utils.JSFUtils;
|
|
|
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>
|
|
|
*
|
|
|
* @author lluis
|
|
|
*/
|
|
|
public class EditarPlano extends AbstractPageBean {
|
|
|
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
|
|
|
|
|
|
/**
|
|
|
* <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 {
|
|
|
}
|
|
|
|
|
|
// </editor-fold>
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
HtmlPanelGrid grid;
|
|
|
PanelGroup pg;
|
|
|
StaticText st;
|
|
|
private HtmlPanelGrid gridLayout = new HtmlPanelGrid();
|
|
|
|
|
|
//Plano actuacao
|
|
|
PlanoActuacao plano;
|
|
|
|
|
|
//HtmlPanelGrid gridPlano = new HtmlPanelGrid();
|
|
|
HtmlPanelGrid gridArea;
|
|
|
HtmlPanelGrid gridRisco;
|
|
|
HtmlPanelGrid gridValor;
|
|
|
HtmlPanelGrid gridMedida;
|
|
|
HtmlPanelGrid gridPosto;
|
|
|
HtmlPanelGrid gridResponsavel;
|
|
|
|
|
|
|
|
|
|
|
|
int risco_id = 0;
|
|
|
int medida_id = 0;
|
|
|
int posto_id = 0;
|
|
|
|
|
|
//page components
|
|
|
TextField txtResponsavelExecucao;
|
|
|
TextField txtPor;
|
|
|
TextArea txtRecursos;
|
|
|
Calendar dtInicio;
|
|
|
Calendar dtFim;
|
|
|
TextArea txtParecerDns;
|
|
|
TextArea txtParecerDl;
|
|
|
TextArea txtVerificacaoSiprp;
|
|
|
|
|
|
|
|
|
public HtmlPanelGrid getGridLayout() {
|
|
|
return gridLayout;
|
|
|
}
|
|
|
|
|
|
public void setGridLayout(HtmlPanelGrid hpg) {
|
|
|
this.gridLayout = hpg;
|
|
|
}
|
|
|
private Button butGravarPlano = new Button();
|
|
|
|
|
|
public Button getButGravarPlano() {
|
|
|
return butGravarPlano;
|
|
|
}
|
|
|
|
|
|
public void setButGravarPlano(Button b) {
|
|
|
this.butGravarPlano = b;
|
|
|
}
|
|
|
private Button butGravarRisco = new Button();
|
|
|
|
|
|
public Button getButGravarRisco() {
|
|
|
return butGravarRisco;
|
|
|
}
|
|
|
|
|
|
public void setButGravarRisco(Button b) {
|
|
|
this.butGravarRisco = b;
|
|
|
}
|
|
|
private Button butEnviar = new Button();
|
|
|
|
|
|
public Button getButEnviar() {
|
|
|
return butEnviar;
|
|
|
}
|
|
|
|
|
|
public void setButEnviar(Button b) {
|
|
|
this.butEnviar = b;
|
|
|
}
|
|
|
private Button butLimparDados = new Button();
|
|
|
|
|
|
public Button getButLimparDados() {
|
|
|
return butLimparDados;
|
|
|
}
|
|
|
|
|
|
public void setButLimparDados(Button b) {
|
|
|
this.butLimparDados = b;
|
|
|
}
|
|
|
private Button butCancelar = new Button();
|
|
|
|
|
|
public Button getButCancelar() {
|
|
|
return butCancelar;
|
|
|
}
|
|
|
|
|
|
public void setButCancelar(Button b) {
|
|
|
this.butCancelar = b;
|
|
|
}
|
|
|
private StaticText lblMsg = new StaticText();
|
|
|
|
|
|
public StaticText getLblMsg() {
|
|
|
return lblMsg;
|
|
|
}
|
|
|
|
|
|
public void setLblMsg(StaticText st) {
|
|
|
this.lblMsg = st;
|
|
|
}
|
|
|
private HtmlPanelGrid gridValidar = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridValidar() {
|
|
|
return gridValidar;
|
|
|
}
|
|
|
|
|
|
public void setGridValidar(HtmlPanelGrid hpg) {
|
|
|
this.gridValidar = hpg;
|
|
|
}
|
|
|
private Checkbox chkValidacao = new Checkbox();
|
|
|
|
|
|
public Checkbox getChkValidacao() {
|
|
|
return chkValidacao;
|
|
|
}
|
|
|
|
|
|
public void setChkValidacao(Checkbox c) {
|
|
|
this.chkValidacao = c;
|
|
|
}
|
|
|
private HtmlInputHidden hidValidacao = new HtmlInputHidden();
|
|
|
|
|
|
public HtmlInputHidden getHidValidacao() {
|
|
|
return hidValidacao;
|
|
|
}
|
|
|
|
|
|
public void setHidValidacao(HtmlInputHidden hih) {
|
|
|
this.hidValidacao = hih;
|
|
|
}
|
|
|
private PanelGroup grpPagination = new PanelGroup();
|
|
|
|
|
|
public PanelGroup getGrpPagination() {
|
|
|
return grpPagination;
|
|
|
}
|
|
|
|
|
|
public void setGrpPagination(PanelGroup pg) {
|
|
|
this.grpPagination = pg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridPagination = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridPagination() {
|
|
|
return gridPagination;
|
|
|
}
|
|
|
|
|
|
public void setGridPagination(HtmlPanelGrid hpg) {
|
|
|
this.gridPagination = hpg;
|
|
|
}
|
|
|
private Button butEnviarCorrecao = new Button();
|
|
|
|
|
|
public Button getButEnviarCorrecao() {
|
|
|
return butEnviarCorrecao;
|
|
|
}
|
|
|
|
|
|
public void setButEnviarCorrecao(Button b) {
|
|
|
this.butEnviarCorrecao = b;
|
|
|
}
|
|
|
private StaticText lblObs = new StaticText();
|
|
|
|
|
|
public StaticText getLblObs() {
|
|
|
return lblObs;
|
|
|
}
|
|
|
|
|
|
public void setLblObs(StaticText st) {
|
|
|
this.lblObs = st;
|
|
|
}
|
|
|
private HtmlPanelGrid gridPlano2 = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getgridPlano2() {
|
|
|
return gridPlano2;
|
|
|
}
|
|
|
|
|
|
public void setgridPlano2(HtmlPanelGrid hpg) {
|
|
|
this.gridPlano2 = hpg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridPlano = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridPlano() {
|
|
|
return gridPlano;
|
|
|
}
|
|
|
|
|
|
public void setGridPlano(HtmlPanelGrid hpg) {
|
|
|
this.gridPlano = hpg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridValidacoes = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridValidacoes() {
|
|
|
return gridValidacoes;
|
|
|
}
|
|
|
|
|
|
public void setGridValidacoes(HtmlPanelGrid hpg) {
|
|
|
this.gridValidacoes = hpg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridValidar2 = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridValidar2() {
|
|
|
return gridValidar2;
|
|
|
}
|
|
|
|
|
|
public void setGridValidar2(HtmlPanelGrid hpg) {
|
|
|
this.gridValidar2 = hpg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridObservacoes = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridObservacoes() {
|
|
|
return gridObservacoes;
|
|
|
}
|
|
|
|
|
|
public void setGridObservacoes(HtmlPanelGrid hpg) {
|
|
|
this.gridObservacoes = hpg;
|
|
|
}
|
|
|
private StaticText stNomeEmpresa = new StaticText();
|
|
|
|
|
|
public StaticText getStNomeEmpresa() {
|
|
|
return stNomeEmpresa;
|
|
|
}
|
|
|
|
|
|
public void setStNomeEmpresa(StaticText st) {
|
|
|
this.stNomeEmpresa = st;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Construct a new Page bean instance.</p>
|
|
|
*/
|
|
|
public EditarPlano() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <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>
|
|
|
*/
|
|
|
@Override
|
|
|
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("PlanoActuacao 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
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.DIRECTOR_LOJA)
|
|
|
{
|
|
|
butEnviarCorrecao.setStyleClass("hidden");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <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>
|
|
|
*/
|
|
|
@Override
|
|
|
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>
|
|
|
*/
|
|
|
@Override
|
|
|
public void prerender() {
|
|
|
FacesContext fc = getFacesContext();
|
|
|
//boolean isPostback = JSFUtils.isPostBack12(fc);
|
|
|
//boolean isPostback = JSFUtils.isPostBack(fc);
|
|
|
boolean isPostback = JSFUtils.isPostback();
|
|
|
System.out.println("POSTBACK : " + isPostback);
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
getRiscosByPlano(p);
|
|
|
if(!isPostback)
|
|
|
{
|
|
|
//initializePlano();
|
|
|
fillValoresHash(p);
|
|
|
initialize(p);
|
|
|
showPlano(p);
|
|
|
//fillPlano();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Boolean validacao = (Boolean) chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue() == true)
|
|
|
{
|
|
|
butEnviarCorrecao.setDisabled(true);
|
|
|
butEnviar.setDisabled(false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
butEnviarCorrecao.setDisabled(false);
|
|
|
butEnviar.setDisabled(true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//setPagination(p);
|
|
|
setPagination();
|
|
|
if(p.getCorrecao().matches("y"))
|
|
|
{
|
|
|
lblObs.setText(p.getObs_correcao());
|
|
|
}
|
|
|
lblMsg.setText(getSessionBean1().getMsg());
|
|
|
getSessionBean1().setMsg("");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <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>
|
|
|
*/
|
|
|
@Override
|
|
|
public void destroy() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected RequestBean1 getRequestBean1() {
|
|
|
return (RequestBean1) getBean("RequestBean1");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected SessionBean1 getSessionBean1() {
|
|
|
return (SessionBean1) getBean("SessionBean1");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected ApplicationBean1 getApplicationBean1() {
|
|
|
return (ApplicationBean1) getBean("ApplicationBean1");
|
|
|
}
|
|
|
|
|
|
public String hyperlink1_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initialize(PlanoActuacao p)
|
|
|
{
|
|
|
//Test.showPlanoTree(p);
|
|
|
//getSessionBean1().setPaginationPageNr(1);
|
|
|
Pagination pagination = new Pagination(p);
|
|
|
getSessionBean1().setPagination(pagination);
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
hidValidacao.setValue("dns");
|
|
|
}
|
|
|
else if(u.getTipo().intValue() == Global.DIRECTOR_LOJA)
|
|
|
{
|
|
|
hidValidacao.setValue("dir_loja");
|
|
|
}
|
|
|
if(u.getTipo().intValue() == Global.TECNICO_HS)
|
|
|
{
|
|
|
hidValidacao.setValue("hs");
|
|
|
}
|
|
|
|
|
|
//gridValidar.setStyleClass("hidden");
|
|
|
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.TECNICO_HS)
|
|
|
{
|
|
|
//gridValidar.setStyleClass("visible");
|
|
|
gridValidar.setRendered(false);
|
|
|
//txtParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
// gridParecer.setStyleClass("");
|
|
|
}
|
|
|
else if(u.getTipo().intValue() == Global.DIRECTOR_LOJA || u.getTipo().intValue() == Global.TECNICO_HS)
|
|
|
{
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
// {
|
|
|
// //txtParecer.setStyleClass("visible");
|
|
|
// txtParecer.setRendered(false);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
if(p.getObservacoes_dl() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dl().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DL: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dl());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if(p.getObservacoes_dns() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dns().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DNS: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dns());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(p.getCorrecao().matches("n"))
|
|
|
{
|
|
|
butEnviar.setText("Enviar a Director de Loja>>");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(p.getFase_antes_correcao().intValue() == Global.FASE_DIR_LOJA_VALIDACAO)
|
|
|
{
|
|
|
butEnviar.setText("Enviar a Director de Loja>>");
|
|
|
}
|
|
|
else if(p.getFase_antes_correcao().intValue() == Global.FASE_DNS_PARECER)
|
|
|
{
|
|
|
butEnviar.setText("Enviar a Director Nacional Seguran<61>a>>");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
//butEnviar.setText("Enviar a Director de Loja");
|
|
|
pg = new PanelGroup();
|
|
|
pg.setId("pgObsDl");
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DL: ");
|
|
|
pg.getChildren().add(st);
|
|
|
TextArea txtObservacoesDl = new TextArea();
|
|
|
txtObservacoesDl.setId("txtObservacoesDl");
|
|
|
txtObservacoesDl.setColumns(200);
|
|
|
txtObservacoesDl.setText(p.getObservacoes_dl());
|
|
|
pg.getChildren().add(txtObservacoesDl);
|
|
|
|
|
|
if(p.getObservacoes_dns() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dns().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DNS: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dns());
|
|
|
pg.getChildren().add(st);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(p.getValidacao_director_loja().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
// gridParecer.setStyleClass("");
|
|
|
butEnviarCorrecao.setDisabled(true);
|
|
|
butEnviar.setDisabled(false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
butEnviarCorrecao.setDisabled(false);
|
|
|
butEnviar.setDisabled(true);
|
|
|
}
|
|
|
butEnviar.setText("Enviar a Director Nacional Seguran<61>a>>");
|
|
|
|
|
|
// if(p.getValidacao_director_loja().booleanValue() == true)
|
|
|
// {
|
|
|
// chkValidacao.setSelected(new Boolean(true));
|
|
|
// butEnviar.setText("Enviar a Director Nacional Seguran<61>a>>");
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// butEnviar.setText("Enviar para Respons<6E>vel de Seguran<61>a>>");
|
|
|
// }
|
|
|
if(p.getCorrecao().matches("y"))
|
|
|
{
|
|
|
butEnviar.setText("Enviar a Director Nacional Seguran<61>a>>");
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// butEnviar.setText("Enviar a Director Nacional Seguran<61>a>>");
|
|
|
// }
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
if(p.getObservacoes_dl() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dl().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
pg.setId("pgObsDl");
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DL: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dl());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
pg.setId("pgObsDns");
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DNS: ");
|
|
|
pg.getChildren().add(st);
|
|
|
TextArea txtObservacoesDns = new TextArea();
|
|
|
txtObservacoesDns.setId("txtObservacoesDns");
|
|
|
txtObservacoesDns.setColumns(200);
|
|
|
txtObservacoesDns.setText(p.getObservacoes_dns());
|
|
|
pg.getChildren().add(txtObservacoesDns);
|
|
|
if(p.getValidacao_dns().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
// gridParecer.setStyleClass("");
|
|
|
butEnviarCorrecao.setDisabled(true);
|
|
|
butEnviar.setDisabled(false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
butEnviarCorrecao.setDisabled(false);
|
|
|
butEnviar.setDisabled(true);
|
|
|
}
|
|
|
|
|
|
// com.sun.webui.jsf.model.Option[] listOptions = new com.sun.webui.jsf.model.Option[2];
|
|
|
//
|
|
|
// listOptions[0] = new Option(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO), "Respons<6E>vel de seguran<61>a");
|
|
|
// listOptions[1] = new Option(new Integer(Global.FASE_DIR_LOJA_VALIDACAO), "Director de loja");
|
|
|
// drpIrPara.setItems(listOptions);
|
|
|
// drpIrPara.setSelected(new Integer( Global.FASE_SEGURANCA_PREENCHIMENTO ));
|
|
|
butEnviar.setText("Enviar para T<>cnico de HS>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
if(p.getObservacoes_dl() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dl().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DL: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dl());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if(p.getObservacoes_dns() != null)
|
|
|
{
|
|
|
if(p.getObservacoes_dns().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
gridObservacoes.getChildren().add(pg);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Observações gerais DNS: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getObservacoes_dns());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// pg = new PanelGroup();
|
|
|
// pg.setId("pgVerSiprp");
|
|
|
// gridObservacoes.getChildren().add(pg);
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText("Verificação SIPRP: ");
|
|
|
// pg.getChildren().add(st);
|
|
|
// TextArea txtVerificacaoSiprp = new TextArea();
|
|
|
// txtVerificacaoSiprp.setId("txtVerificacaoSiprp");
|
|
|
// txtVerificacaoSiprp.setColumns(200);
|
|
|
// txtVerificacaoSiprp.setText(p.getVerificacao_siprp());
|
|
|
// pg.getChildren().add(txtVerificacaoSiprp);
|
|
|
|
|
|
if(p.getValidacao_hs().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
butEnviar.setDisabled(false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
butEnviar.setDisabled(true);
|
|
|
}
|
|
|
butEnviar.setText("Concluir");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// gridPlano.setId("gridPlano");
|
|
|
// gridPlano.setWidth("100%");
|
|
|
// gridPlano.setColumns(1);
|
|
|
// gridPlano.setColumnClasses("gridColCenter");
|
|
|
//plano
|
|
|
//lblTop.setText("Plano de actuação da auditoria " + p.getData_visita_str());
|
|
|
gridLayout.getChildren().add(gridPlano);
|
|
|
}
|
|
|
|
|
|
private void showPlano(PlanoActuacao p)
|
|
|
{
|
|
|
//stNomeEmpresa.setText(p.getNome_empresa());
|
|
|
gridArea = new HtmlPanelGrid();
|
|
|
gridArea.setId("gridArea");
|
|
|
gridArea.setColumns(1);
|
|
|
gridArea.setColumnClasses("gridColCenter");
|
|
|
gridArea.setWidth("100%");
|
|
|
gridArea.setStyle("background-color: #f6f4e8; border: solid 1px #766c6c");
|
|
|
|
|
|
gridPlano.getChildren().add(gridArea);
|
|
|
|
|
|
if(p.getAreas().size() > 0)
|
|
|
{
|
|
|
Area a = p.getAreas().get(0);
|
|
|
showArea(a);
|
|
|
if(a.getRiscos().size() > 0)
|
|
|
{
|
|
|
Risco r = a.getRiscos().get(0);
|
|
|
showRisco(r);
|
|
|
//showValores(r);
|
|
|
////if(r.getValores().size() > 0)
|
|
|
////{
|
|
|
// showValor(r.getValores().get(0));
|
|
|
showValor(r);
|
|
|
// showResponsavel(r.getValores().get(0));
|
|
|
showResponsavel(r);
|
|
|
////}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
showPreviousValidacoes(p);
|
|
|
}
|
|
|
|
|
|
private void showArea(Area a)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Área: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(Utils.unicodeToHTML(a.getDescricao()));
|
|
|
pg.getChildren().add(st);
|
|
|
gridArea.getChildren().add(pg);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showRisco(Risco r)
|
|
|
{
|
|
|
getSessionBean1().setCurrentRisco(r);
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
//grd.setStyleClass("centerBlock");
|
|
|
// gridArea.getChildren().add(grd);
|
|
|
|
|
|
gridRisco = new HtmlPanelGrid();
|
|
|
//gridRisco.setStyleClass("centerBlock");
|
|
|
gridRisco.setWidth("98%");
|
|
|
gridRisco.setColumns(1);
|
|
|
gridRisco.setColumnClasses("gridColLeft");
|
|
|
//grd.getChildren().add(gridRisco);
|
|
|
gridArea.getChildren().add(gridRisco);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Risco: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showValores(Risco r)
|
|
|
{
|
|
|
List<Valor> valores = r.getValores();
|
|
|
|
|
|
for(Valor v : valores)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setColumnClasses("gridColLeft");
|
|
|
grd.setWidth("100%");
|
|
|
//grd.setStyleClass("centerBlock");
|
|
|
////gridRisco.getChildren().add(grd);
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridRisco.getChildren().add(gridValor);
|
|
|
//gridValor.setStyleClass("centerBlock");
|
|
|
gridValor.setWidth("100%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
//grd.getChildren().add(gridValor);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Valor: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(v.getValor().toString());
|
|
|
pg.getChildren().add(st);
|
|
|
gridValor.getChildren().add(pg);
|
|
|
|
|
|
showMedidas(r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// private void showValor(Valor v)
|
|
|
private void showValor(Risco r)
|
|
|
{
|
|
|
//Valor v = r.getValores().get(0);
|
|
|
// getSessionBean1().setCurrentValor(v);
|
|
|
getSessionBean1().setCurrentRisco(r);
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setColumnClasses("gridColLeft");
|
|
|
grd.setWidth("100%");
|
|
|
//grd.setStyleClass("centerBlock");
|
|
|
////gridRisco.getChildren().add(grd);
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridRisco.getChildren().add(gridValor);
|
|
|
//gridValor.setStyleClass("centerBlock");
|
|
|
gridValor.setWidth("100%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
//grd.getChildren().add(gridValor);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Valor: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
if(r.getValor() == null)
|
|
|
{
|
|
|
st.setText(" - ");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
st.setText(r.getValor().toString());
|
|
|
}
|
|
|
|
|
|
pg.getChildren().add(st);
|
|
|
gridValor.getChildren().add(pg);
|
|
|
|
|
|
showMedidas(r);
|
|
|
}
|
|
|
|
|
|
private void showMedidas(Risco r)
|
|
|
{
|
|
|
List<Medida> medidas = r.getMedidas();
|
|
|
|
|
|
for(Medida m : medidas)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridValor.getChildren().add(grd);
|
|
|
|
|
|
gridMedida = new HtmlPanelGrid();
|
|
|
gridMedida.setStyleClass("centerBlock");
|
|
|
gridMedida.setWidth("98%");
|
|
|
gridMedida.setColumns(1);
|
|
|
gridMedida.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridMedida);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Medida: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(m.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridMedida.getChildren().add(pg);
|
|
|
|
|
|
showPostos(m);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showPostos(Medida m)
|
|
|
{
|
|
|
List<PostoTrabalho> postos = m.getPostos();
|
|
|
|
|
|
for(PostoTrabalho p : postos)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridMedida.getChildren().add(grd);
|
|
|
|
|
|
gridPosto = new HtmlPanelGrid();
|
|
|
gridPosto.setStyleClass("centerBlock");
|
|
|
gridPosto.setWidth("98%");
|
|
|
gridPosto.setColumns(1);
|
|
|
gridPosto.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridPosto);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Posto de trabalho: ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridPosto.getChildren().add(pg);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// private void showResponsavel(Valor v)
|
|
|
private void showResponsavel(Risco r)
|
|
|
{
|
|
|
System.out.println("RISCO : " + r.getDescricao() + " RESPONSAVEL : " + r.getResponsavel_execucao());
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
gridResponsavel = new HtmlPanelGrid();
|
|
|
gridResponsavel.setId("gridResponsavel");
|
|
|
gridResponsavel.setWidth("100%");
|
|
|
gridResponsavel.setColumns(1);
|
|
|
gridResponsavel.setColumnClasses("gridColLeft");
|
|
|
gridArea.getChildren().add(gridResponsavel);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
pg.setId("pgResponsavel");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Responsável de execução:");
|
|
|
pg.getChildren().add(st);
|
|
|
if(u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
txtResponsavelExecucao = new TextField();
|
|
|
txtResponsavelExecucao.setId("txtResponsavel");
|
|
|
txtResponsavelExecucao.setColumns(100);
|
|
|
txtResponsavelExecucao.setText(r.getResponsavel_execucao());
|
|
|
pg.getChildren().add(txtResponsavelExecucao);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getResponsavel_execucao());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
pg.getChildren().add(st);
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("POR:");
|
|
|
pg.getChildren().add(st);
|
|
|
|
|
|
if(u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
txtPor = new TextField();
|
|
|
txtPor.setId("txtPor");
|
|
|
txtPor.setColumns(20);
|
|
|
txtPor.setText(r.getPor());
|
|
|
pg.getChildren().add(txtPor);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getPor());
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Recursos necessários à implementação da medida: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
if(u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
txtRecursos = new TextArea();
|
|
|
txtRecursos.setId("txtRecursos");
|
|
|
txtRecursos.setColumns(200);
|
|
|
txtRecursos.setText(r.getRecursos_necessarios());
|
|
|
gridResponsavel.getChildren().add(txtRecursos);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getRecursos_necessarios());
|
|
|
//gridResponsavel.getChildren().add(st);
|
|
|
pg.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
// Anchor ancora = new Anchor();
|
|
|
// ancora.setId("calendario");
|
|
|
// gridResponsavel.getChildren().add(ancora);
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(2);
|
|
|
grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
grd.setId("gridDtInicio");
|
|
|
grd.setStyle("width: 100%");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Data prevista de início:");
|
|
|
grd.getChildren().add(st);
|
|
|
if(u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
dtInicio = new Calendar();
|
|
|
dtInicio.setId("dtInicio");
|
|
|
|
|
|
dtInicio.setDateFormatPattern("dd-MM-yyyy");
|
|
|
dtInicio.setValue(r.getData_inicio());
|
|
|
java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar();
|
|
|
gcalendar.set(2000,1,1);
|
|
|
dtInicio.setMinDate(gcalendar.getTime());
|
|
|
grd.getChildren().add(dtInicio);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(r.getData_inicio() != null)
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
String data_str = formatter.format(r.getData_inicio());
|
|
|
st.setText(data_str);
|
|
|
grd.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
gridResponsavel.getChildren().add(grd);
|
|
|
|
|
|
|
|
|
grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(2);
|
|
|
grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
grd.setId("gridDtFim");
|
|
|
grd.setStyle("width: 100%");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Data prevista de conclusão:");
|
|
|
grd.getChildren().add(st);
|
|
|
if(u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
dtFim = new Calendar();
|
|
|
dtFim.setId("dtFim");
|
|
|
dtFim.setDateFormatPattern("dd-MM-yyyy");
|
|
|
java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar();
|
|
|
gcalendar1.set(2099,1,1);
|
|
|
dtFim.setMaxDate(gcalendar1.getTime());
|
|
|
dtFim.setValue(r.getData_fim());
|
|
|
grd.getChildren().add(dtFim);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(r.getData_fim() != null)
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
String data_str = formatter.format(r.getData_fim());
|
|
|
st.setText(data_str);
|
|
|
grd.getChildren().add(st);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
gridResponsavel.getChildren().add(grd);
|
|
|
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_LOJA)
|
|
|
{
|
|
|
if(r.getParecer_dl() != null)
|
|
|
{
|
|
|
if(r.getParecer_dl().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Parecer Director de Loja: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
// if(u.getTipo().intValue() == Global.DIRECTOR_LOJA)
|
|
|
// {
|
|
|
// txtParecerDl = new TextArea();
|
|
|
// txtParecerDl.setId("txtParecerDl");
|
|
|
// txtParecerDl.setColumns(200);
|
|
|
// txtParecerDl.setText(v.getParecer_dl());
|
|
|
// gridResponsavel.getChildren().add(txtParecerDl);
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getParecer_dl());
|
|
|
//gridResponsavel.getChildren().add(st);
|
|
|
pg.getChildren().add(st);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Parecer Director de Loja: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
txtParecerDl = new TextArea();
|
|
|
txtParecerDl.setId("txtParecerDl");
|
|
|
txtParecerDl.setColumns(200);
|
|
|
txtParecerDl.setText(r.getParecer_dl());
|
|
|
gridResponsavel.getChildren().add(txtParecerDl);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
if(r.getParecer_dns() != null)
|
|
|
{
|
|
|
if(r.getParecer_dns().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Parecer Director Nacional de Segurança: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
// if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
// {
|
|
|
// txtParecerDns = new TextArea();
|
|
|
// txtParecerDns.setId("txtParecerDns");
|
|
|
// txtParecerDns.setColumns(200);
|
|
|
// txtParecerDns.setText(v.getParecer_dns());
|
|
|
// gridResponsavel.getChildren().add(txtParecerDns);
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getParecer_dns());
|
|
|
//gridResponsavel.getChildren().add(st);
|
|
|
pg.getChildren().add(st);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Parecer Director Nacional de Segurança: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
txtParecerDns = new TextArea();
|
|
|
txtParecerDns.setId("txtParecerDns");
|
|
|
txtParecerDns.setColumns(200);
|
|
|
txtParecerDns.setText(r.getParecer_dns());
|
|
|
gridResponsavel.getChildren().add(txtParecerDns);
|
|
|
|
|
|
}
|
|
|
|
|
|
//Verificacao SIPRP
|
|
|
if(u.getTipo().intValue() != Global.TECNICO_HS)
|
|
|
{
|
|
|
if(r.getVerificacao_siprp() != null)
|
|
|
{
|
|
|
if(r.getVerificacao_siprp().trim().length() > 0)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Verificação SIPRP: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
// if(u.getTipo().intValue() == Global.TECNICO_HS)
|
|
|
// {
|
|
|
// txtVerificacaoSiprp = new TextArea();
|
|
|
// txtVerificacaoSiprp.setId("txtVerificacaoSiprp");
|
|
|
// txtVerificacaoSiprp.setColumns(200);
|
|
|
// txtVerificacaoSiprp.setText(v.getVerificacao_siprp());
|
|
|
// gridResponsavel.getChildren().add(txtVerificacaoSiprp);
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getVerificacao_siprp());
|
|
|
//gridResponsavel.getChildren().add(st);
|
|
|
pg.getChildren().add(st);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Verificação SIPRP: ");
|
|
|
pg.getChildren().add(st);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
|
|
|
txtVerificacaoSiprp = new TextArea();
|
|
|
txtVerificacaoSiprp.setId("txtVerificacaoSiprp");
|
|
|
txtVerificacaoSiprp.setColumns(200);
|
|
|
txtVerificacaoSiprp.setText(r.getVerificacao_siprp());
|
|
|
gridResponsavel.getChildren().add(txtVerificacaoSiprp);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showPreviousValidacoes(PlanoActuacao p)
|
|
|
{
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
int tipo = u.getTipo().intValue();
|
|
|
|
|
|
switch(tipo)
|
|
|
{
|
|
|
case Global.DIRECTOR_NACIONAL_SEGURANCA:
|
|
|
if(p.getValidacao_director_loja().booleanValue())
|
|
|
{
|
|
|
StaticText st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
//st.setStyleClass("label");
|
|
|
String nome = "";
|
|
|
try
|
|
|
{
|
|
|
Utilizador user = udp.getUtilizador(p.getUser_dir_loja());
|
|
|
nome = user.getNome();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
st.setText("Validado por " + nome + " (Director de Loja) a " + p.getData_validacao_dir_loja_str());
|
|
|
gridValidacoes.getChildren().add(st);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.TECNICO_HS:
|
|
|
if(p.getValidacao_director_loja().booleanValue())
|
|
|
{
|
|
|
StaticText st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
//st.setStyleClass("label");
|
|
|
String nome = "";
|
|
|
try
|
|
|
{
|
|
|
Utilizador user = udp.getUtilizador(p.getUser_dir_loja());
|
|
|
nome = user.getNome();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
st.setText("Validado por " + nome + " (Director de Loja) a " + p.getData_validacao_dir_loja_str());
|
|
|
gridValidacoes.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
if(p.getValidacao_dns().booleanValue())
|
|
|
{
|
|
|
StaticText st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
//st.setStyleClass("label");
|
|
|
String nome = "";
|
|
|
try
|
|
|
{
|
|
|
Utilizador user = udp.getUtilizador(p.getUser_dns());
|
|
|
nome = user.getNome();
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
st.setText("Validado por " + nome + " (Director Nacional de Segurança) a " + p.getData_validacao_dns_str());
|
|
|
//st.setText("Validado por Director Nacional de Segurança");
|
|
|
gridValidacoes.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void setPagination()
|
|
|
{
|
|
|
StaticText st = null;
|
|
|
|
|
|
Class[] argtypes = new Class[1];
|
|
|
argtypes[0] = ActionEvent.class;
|
|
|
MethodExpression me = (MethodExpression)this.getApplication().getExpressionFactory().createMethodExpression(
|
|
|
getFacesContext().getELContext(), "#{EditarPlano.paginacao_actionListener}", null,argtypes);
|
|
|
|
|
|
if(grpPagination.getChildCount() > 0)
|
|
|
{
|
|
|
grpPagination.getChildren().clear();
|
|
|
}
|
|
|
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
Vector<Pagina> paginas = pagination.getPaginas();
|
|
|
for(Pagina pagina : paginas)
|
|
|
{
|
|
|
if(pagina.isPrevious())
|
|
|
{
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
}
|
|
|
else if(pagina.isNext())
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
if(pagina.getPage_nr().intValue() < pagination.totalPaginas() )
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" | ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String butGravarPlano_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
try
|
|
|
{
|
|
|
gravarPlano();
|
|
|
getSessionBean1().setMsg("Os dados do Plano de Actuação foram guardados");
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
getSessionBean1().setMsg("Erro na gravação do plano!");
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private void gravarPlano() throws Exception
|
|
|
{
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dl("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dl((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_director_loja(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dns("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dns((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_dns(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_hs(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
pdp.updatePlano(p);
|
|
|
|
|
|
//Valor curValor = getSessionBean1().getCurrentValor();
|
|
|
Risco curValor = getSessionBean1().getCurrentRisco();
|
|
|
curValor = fillValorFields(curValor);
|
|
|
// getSessionBean1().getValoresHash().remove(curValor.getId());
|
|
|
// getSessionBean1().getValoresHash().put(curValor.getId(), curValor);
|
|
|
getSessionBean1().getRiscosHash().remove(curValor.getId());
|
|
|
getSessionBean1().getRiscosHash().put(curValor.getId(), curValor);
|
|
|
|
|
|
// HashMap<Integer, Valor> valores = getSessionBean1().getValoresHash();
|
|
|
// Iterator<Integer> iter = valores.keySet().iterator();
|
|
|
// while(iter.hasNext())
|
|
|
// {
|
|
|
// Integer id = iter.next();
|
|
|
// Valor v = valores.get(id);
|
|
|
// pdp.updateValor(v);
|
|
|
// }
|
|
|
|
|
|
HashMap<Integer, Risco> valores = getSessionBean1().getRiscosHash();
|
|
|
Iterator<Integer> iter = valores.keySet().iterator();
|
|
|
while(iter.hasNext())
|
|
|
{
|
|
|
Integer id = iter.next();
|
|
|
Risco r = valores.get(id);
|
|
|
pdp.updateRisco(r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String butGravarRisco_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dl("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dl((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_director_loja(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dns("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dns((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_dns(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao != null)
|
|
|
{
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
p.setValidacao_hs(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
pdp.updatePlano(p);
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
|
|
|
|
|
|
try
|
|
|
{
|
|
|
// Risco r = getSessionBean1().getCurrentRisco();
|
|
|
// r = fillRiscoFields(r);
|
|
|
// pdp.updateRisco(r);
|
|
|
|
|
|
//Valor v = getSessionBean1().getCurrentValor();
|
|
|
Risco r = getSessionBean1().getCurrentRisco();
|
|
|
r = fillValorFields(r);
|
|
|
//pdp.updateValor(r);
|
|
|
pdp.updateRisco(r);
|
|
|
// getSessionBean1().getValoresHash().remove(r.getId());
|
|
|
// getSessionBean1().getValoresHash().put(r.getId(), r);
|
|
|
getSessionBean1().getRiscosHash().remove(r.getId());
|
|
|
getSessionBean1().getRiscosHash().put(r.getId(), r);
|
|
|
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
|
|
|
////r = pagination.nextRisco();
|
|
|
r = pagination.nextValor();
|
|
|
//Risco r = getSessionBean1().getRiscosHash().get(r.getId());
|
|
|
///////r = getSessionBean1().getRiscosHash().get(r.getId());
|
|
|
Area a = getSessionBean1().getAreasHash().get(r.getArea_id());
|
|
|
//if(v != null)
|
|
|
if(r != null)
|
|
|
{
|
|
|
//gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
if(gridArea.getChildren() != null)
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
showArea(a);
|
|
|
showRisco(r);
|
|
|
showValor(r);
|
|
|
showResponsavel(r);
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
|
|
|
//Risco r = getNextRisco(getSessionBean1().getPlanoId());
|
|
|
//fillRisco(r);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private void fillPlanoFields()
|
|
|
{
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
p.setValidacao_hs(validacao);
|
|
|
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dl((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.DIRECTOR_NACIONAL_SEGURANCA:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
p.setValidacao_hs(validacao);
|
|
|
|
|
|
txtObs = (TextArea) pg.findComponent("txtObservacoesDns");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dns((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
p.setValidacao_hs(validacao);
|
|
|
break;
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// private Valor fillValorFields(Valor v)
|
|
|
private Risco fillValorFields(Risco r)
|
|
|
{
|
|
|
//gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel");
|
|
|
|
|
|
TextField txtResponsavel = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtResponsavel");
|
|
|
if(txtResponsavel != null)
|
|
|
{
|
|
|
if(txtResponsavel.getText() != null)
|
|
|
{
|
|
|
r.setResponsavel_execucao((String) txtResponsavel.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextField txtPor = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtPor");
|
|
|
if(txtPor != null)
|
|
|
{
|
|
|
if(txtPor.getText() != null)
|
|
|
{
|
|
|
r.setPor((String) txtPor.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextArea txtRecursos = (TextArea) gridResponsavel.findComponent("form1:txtRecursos");
|
|
|
if(txtRecursos != null)
|
|
|
{
|
|
|
if(txtRecursos.getText() != null)
|
|
|
{
|
|
|
r.setRecursos_necessarios((String) txtRecursos.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Calendar dtInicio = (Calendar) gridResponsavel.findComponent("form1:dtInicio:");
|
|
|
if(dtInicio != null)
|
|
|
{
|
|
|
r.setData_inicio(dtInicio.getSelectedDate());
|
|
|
}
|
|
|
|
|
|
Calendar dtFim = (Calendar) gridResponsavel.findComponent("form1:dtFim");
|
|
|
if(dtFim != null)
|
|
|
{
|
|
|
r.setData_fim(dtFim.getSelectedDate());
|
|
|
}
|
|
|
|
|
|
TextArea txtParecerDl = (TextArea) gridResponsavel.findComponent("form1:txtParecerDl");
|
|
|
if(txtParecerDl != null)
|
|
|
{
|
|
|
if(txtParecerDl.getText() != null)
|
|
|
{
|
|
|
r.setParecer_dl((String) txtParecerDl.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextArea txtParecerDns = (TextArea) gridResponsavel.findComponent("form1:txtParecerDns");
|
|
|
if(txtParecerDns != null)
|
|
|
{
|
|
|
if(txtParecerDns.getText() != null)
|
|
|
{
|
|
|
r.setParecer_dns((String) txtParecerDns.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextArea txtVerificacaoSiprp = (TextArea) gridResponsavel.findComponent("form1:txtVerificacaoSiprp");
|
|
|
if(txtVerificacaoSiprp != null)
|
|
|
{
|
|
|
if(txtVerificacaoSiprp.getText() != null)
|
|
|
{
|
|
|
r.setVerificacao_siprp((String) txtVerificacaoSiprp.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
public String butEnviar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
|
|
|
if(planoValidationOk(p))
|
|
|
{
|
|
|
//Valor curValor = getSessionBean1().getCurrentValor();
|
|
|
Risco curValor = getSessionBean1().getCurrentRisco();
|
|
|
curValor = fillValorFields(curValor);
|
|
|
getSessionBean1().getRiscosHash().remove(curValor.getId());
|
|
|
getSessionBean1().getRiscosHash().put(curValor.getId(), curValor);
|
|
|
if(!checkCamposObrigatorios())
|
|
|
{
|
|
|
getSessionBean1().setMsg("Faltam preencher alguns riscos/valor. Por favor preencha todos os campos antes de prosseguir");
|
|
|
return null;
|
|
|
}
|
|
|
try //save current valor
|
|
|
{
|
|
|
// Valor v = getSessionBean1().getCurrentValor();
|
|
|
// v = fillValorFields(v);
|
|
|
// pdp.updateValor(v);
|
|
|
|
|
|
HashMap<Integer, Risco> valores = getSessionBean1().getRiscosHash();
|
|
|
Iterator<Integer> iter = valores.keySet().iterator();
|
|
|
while(iter.hasNext())
|
|
|
{
|
|
|
Integer id = iter.next();
|
|
|
Risco r = valores.get(id);
|
|
|
pdp.updateRisco(r);
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
processEnviar(p);
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Erro no envio do Plano");
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private boolean planoValidationOk(PlanoActuacao p)
|
|
|
{
|
|
|
boolean ok = true;
|
|
|
boolean processo_validado = true;
|
|
|
int dns_next_fase = 2;
|
|
|
|
|
|
int fase = p.getFase().intValue();
|
|
|
p.setFase_anterior(new Integer(fase));
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel");
|
|
|
HtmlPanelGrid gridDtInicio = (HtmlPanelGrid) gridResponsavel.findComponent("form1:gridDtInicio");
|
|
|
Calendar calDtInicio = (Calendar) gridDtInicio.findComponent("form1:dtInicio");
|
|
|
HtmlPanelGrid gridDtFim = (HtmlPanelGrid) gridResponsavel.findComponent("form1:gridDtFim");
|
|
|
Calendar calDtFim = (Calendar) gridDtFim.findComponent("form1:dtFim");
|
|
|
Date dtInicio = calDtInicio.getSelectedDate();
|
|
|
Date dtFim = calDtFim.getSelectedDate();
|
|
|
if(dtInicio != null && dtFim != null)
|
|
|
{
|
|
|
if(dtInicio.after(dtFim))
|
|
|
{
|
|
|
getSessionBean1().setMsg("Data Início não pode ser superior à data fim!");
|
|
|
ok = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
ok = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
p.setValidacao_hs(new Boolean(true));
|
|
|
Date today = new Date();
|
|
|
p.setData_validacao_hs(today);
|
|
|
p.setUser_hs(getSessionBean1().getCurrentUser().getId());
|
|
|
|
|
|
// PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgVerSiprp");
|
|
|
// if(pg != null)
|
|
|
// {
|
|
|
// TextArea txtVer = (TextArea) pg.findComponent("txtVerificacaoSiprp");
|
|
|
// if(txtVer != null)
|
|
|
// {
|
|
|
// p.setVerificacao_siprp("");
|
|
|
// if(txtVer.getText() != null)
|
|
|
// {
|
|
|
// p.setVerificacao_siprp((String) txtVer.getText());
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
getSessionBean1().setMsg("É necess<73>rio validar o processo antes de dar seguimento para a fase seguinte!");
|
|
|
ok = false;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
p.setValidacao_director_loja(new Boolean(true));
|
|
|
Date today = new Date();
|
|
|
p.setData_validacao_dir_loja(today);
|
|
|
p.setUser_dir_loja(getSessionBean1().getCurrentUser().getId());
|
|
|
|
|
|
PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dl("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dl((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
fase = Global.FASE_SEGURANCA_PREENCHIMENTO; //fase 2
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
p.setValidacao_dns(new Boolean(true));
|
|
|
Date today = new Date();
|
|
|
p.setData_validacao_dns(today);
|
|
|
p.setUser_dns(getSessionBean1().getCurrentUser().getId());
|
|
|
|
|
|
PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns");
|
|
|
if(txtObs != null)
|
|
|
{
|
|
|
p.setObservacoes_dns("");
|
|
|
if(txtObs.getText() != null)
|
|
|
{
|
|
|
p.setObservacoes_dns((String) txtObs.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
// if(txtParecer.getText() == null)
|
|
|
// {
|
|
|
// getSessionBean1().setMsg("Tem de preencher parecer!");
|
|
|
// ok = false;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// String parecer = (String) txtParecer.getText();
|
|
|
// if(parecer.trim().length() == 0)
|
|
|
// {
|
|
|
// getSessionBean1().setMsg("Tem de preencher parecer!");
|
|
|
// ok = false;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// p.setParecer_dns(parecer);
|
|
|
// fase++;
|
|
|
// }
|
|
|
// }
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
getSessionBean1().setMsg("É necess<73>rio validar o processo antes de dar seguimento para a fase seguinte!");
|
|
|
ok = false;
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// Integer irPara = (Integer)drpIrPara.getSelected();
|
|
|
// dns_next_fase = irPara.intValue();
|
|
|
// fase = dns_next_fase;
|
|
|
// }
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// if(!checkCamposObrigatorios())
|
|
|
// {
|
|
|
// ok = false;
|
|
|
// getSessionBean1().setMsg("Faltam preencher alguns riscos/valor. Por favor preencha todos os campos antes de prosseguir");
|
|
|
// }
|
|
|
|
|
|
if(ok)
|
|
|
{
|
|
|
if(p.getCorrecao().matches("y"))
|
|
|
{
|
|
|
fase = p.getFase_antes_correcao().intValue();
|
|
|
p.setCorrecao("n");
|
|
|
p.setObs_correcao("");
|
|
|
}
|
|
|
|
|
|
p.setFase(new Integer(fase));
|
|
|
}
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
}
|
|
|
|
|
|
private boolean checkCamposObrigatorios()
|
|
|
{
|
|
|
boolean res = true;
|
|
|
HashMap<Integer, Risco> valores = getSessionBean1().getRiscosHash();
|
|
|
Iterator<Integer> iter = valores.keySet().iterator();
|
|
|
while(iter.hasNext())
|
|
|
{
|
|
|
Integer id = iter.next();
|
|
|
// Valor v = valores.get(id);
|
|
|
Risco r = valores.get(id);
|
|
|
if(r.getResponsavel_execucao() == null)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
else if(r.getResponsavel_execucao().trim().length() == 0)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(r.getPor() == null)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
else if(r.getPor().trim().length() == 0)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(r.getRecursos_necessarios() == null)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
else if(r.getRecursos_necessarios().trim().length() == 0)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(r.getData_inicio() == null)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(r.getData_fim() == null)
|
|
|
{
|
|
|
res = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
private void processEnviar(PlanoActuacao p) throws Exception
|
|
|
{
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
p.setObs_correcao("");
|
|
|
pdp.updatePlano(p);
|
|
|
enviarMail(p);
|
|
|
}
|
|
|
|
|
|
|
|
|
public void enviarMail(PlanoActuacao p)
|
|
|
{
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
Mail mail = new Mail();
|
|
|
String assunto = "";
|
|
|
String mail_text = "";
|
|
|
|
|
|
int fase = p.getFase().intValue();
|
|
|
int tipo_utilizador = 0;
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
if(p.getFase_anterior() == null )
|
|
|
{
|
|
|
assunto = "PLANOS - SEGURAN<41>A (PREENCHIMENTO)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Seguran<61>a(Preenchimento)";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
switch(p.getFase_anterior().intValue())
|
|
|
{
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
tipo_utilizador = Global.DIRECTOR_LOJA;
|
|
|
assunto = "Plano de Actua<75><61>o da Avalia<69><61>o de Riscos de " + p.getData_visita_str() + " - Pedido de Correc<65><63>o";
|
|
|
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
|
|
|
mail_text += "<p>O Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " foi devolvido para correcção.</p>";
|
|
|
mail_text += "<p>Proceda, por favor, em www.siprp.com à(s) respectiva(s) correcção(ões) de acordo com as indicações e volte a reenviar o processo para a fase seguinte.</p>";
|
|
|
mail_text += "<p>Caso tenha alguma dúvida ou necessite de qualquer esclarecimento, contacte, por favor, a Área Técnica da SIPRP através do telefone 213 504 540.</p>";
|
|
|
mail_text += "<p>Cumprimentos,</p>";
|
|
|
mail_text += "<p>A equipa da SIPRP</p>";
|
|
|
mail_text += "<p><center><b>Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático</b></center></p>";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
tipo_utilizador = Global.DIRECTOR_LOJA;
|
|
|
assunto = "Plano de Actua<75><61>o da Avalia<69><61>o de Riscos de " + p.getData_visita_str();
|
|
|
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
|
|
|
mail_text += "<p>Encontra-se disponível em <a>www.siprp.com</a> o Plano de Actuação referente à auditoria de ";
|
|
|
mail_text += "Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa ";
|
|
|
mail_text += "validar a informação preenchida.</p>";
|
|
|
mail_text += "<p>Cumprimentos.</p>";
|
|
|
mail_text += "<p><center><b>Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático</b></center></p>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
tipo_utilizador = Global.DIRECTOR_NACIONAL_SEGURANCA;
|
|
|
assunto = "Plano de Actua<75><61>o da Avalia<69><61>o de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento();
|
|
|
mail_text = "<p>Exmo. Senhor Silvestre Machado,</p>";
|
|
|
mail_text += "<p>Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que o possa validar.</p>";
|
|
|
mail_text += "<p>Cumprimentos.</p>";
|
|
|
mail_text += "<p><center><b>Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático</b></center></p>";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
tipo_utilizador = Global.TECNICO_HS;
|
|
|
assunto = "Plano de Actua<75><61>o da Avalia<69><61>o de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento();
|
|
|
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
|
|
|
mail_text += "<p>Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa efectuar a sua verificação.</p>";
|
|
|
mail_text += "<p><center><b>Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático</b></center></p>";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_CONCLUIDO:
|
|
|
assunto = "Plano de Actua<75><61>o da Avalia<69><61>o de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento() + " - Processo finalizado";
|
|
|
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
|
|
|
mail_text += "<p>Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " finalizado após verificação pelos Técnicos Superiores de Higiene e Segurança da SIPRP.</p>";
|
|
|
mail_text += "<p>Aproveitamos para agradecer toda a disponibilidade e ficamos ao vosso dispor, caso tenha alguma dúvida ou necessite de qualquer esclarecimento, através do telefone 213 504 540.</p>";
|
|
|
mail_text += "<p>Cumprimentos,</p>";
|
|
|
mail_text += "<p><center><b>Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático</b></center></p>";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(fase < Global.FASE_CONCLUIDO) // nao envia para ninguem na fase Concluido
|
|
|
{
|
|
|
String responsavel_loja = "n";
|
|
|
if(tipo_utilizador == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
responsavel_loja = "y";
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
ArrayList list = udp.getUtilizadoresListByTipo(tipo_utilizador, responsavel_loja, p.getEstabelecimento_id());
|
|
|
ListIterator iter = list.listIterator();
|
|
|
while(iter.hasNext())
|
|
|
{
|
|
|
Utilizador u = (Utilizador) iter.next();
|
|
|
System.out.println("USER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail());
|
|
|
try
|
|
|
{
|
|
|
mail.send(u.getEmail(), Mail.ENDERECO_ENVIO, assunto, mail_text);
|
|
|
System.out.println("EMAIL ENVIADO !!");
|
|
|
}
|
|
|
catch(Exception ex1)
|
|
|
{
|
|
|
ex1.printStackTrace();
|
|
|
System.out.println("MAIL ERROR : " + ex1.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
else //fase concluido
|
|
|
{
|
|
|
int[] users = new int[]{Global.RESPONSAVEL_SEGURANCA, Global.DIRECTOR_LOJA, Global.DIRECTOR_NACIONAL_SEGURANCA};
|
|
|
for(int i=0; i < users.length; i++)
|
|
|
{
|
|
|
tipo_utilizador = users[i];
|
|
|
|
|
|
String responsavel_loja = "n";
|
|
|
if(tipo_utilizador == Global.RESPONSAVEL_SEGURANCA)
|
|
|
{
|
|
|
responsavel_loja = "y";
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
ArrayList list = udp.getUtilizadoresListByTipo(tipo_utilizador, responsavel_loja, p.getEstabelecimento_id());
|
|
|
ListIterator iter = list.listIterator();
|
|
|
while(iter.hasNext())
|
|
|
{
|
|
|
Utilizador u = (Utilizador) iter.next();
|
|
|
System.out.println("USER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail());
|
|
|
try
|
|
|
{
|
|
|
mail.send(u.getEmail(), Mail.ENDERECO_ENVIO, assunto, mail_text);
|
|
|
System.out.println("EMAIL ENVIADO !!");
|
|
|
}
|
|
|
catch(Exception ex1)
|
|
|
{
|
|
|
ex1.printStackTrace();
|
|
|
System.out.println("MAIL ERROR : " + ex1.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// catch(Exception ex)
|
|
|
// {
|
|
|
// //ex.printStackTrace();
|
|
|
// }
|
|
|
// Mail mail = new Mail();
|
|
|
// try
|
|
|
// {
|
|
|
// mail.send("lluis@evolute.pt", Mail.ENDERECO_ENVIO, assunto, mail_text);
|
|
|
// System.out.println("EMAIL ENVIADO !!");
|
|
|
// }
|
|
|
// catch(Exception ex)
|
|
|
// {
|
|
|
// ex.printStackTrace();
|
|
|
// System.out.println("ERRO NO ENVIO DO EMAIL !!");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public void chkValidacao_processValueChange(ValueChangeEvent event) {
|
|
|
// if(chkValidacao.getSelected() != null)
|
|
|
// {
|
|
|
// Boolean selected = (Boolean) chkValidacao.getSelected();
|
|
|
// if(selected.booleanValue())
|
|
|
// {
|
|
|
// //txtParecer.setRendered(true);
|
|
|
// gridParecer.setStyleClass("visible");
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// //txtParecer.setRendered(false);
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
// }
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// //txtParecer.setRendered(false);
|
|
|
// gridParecer.setStyleClass("hidden");
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
public void drpIrPara_processValueChange(ValueChangeEvent event) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private void getRiscosByPlano(PlanoActuacao p)
|
|
|
{
|
|
|
HashMap areasHash = new HashMap();
|
|
|
HashMap riscosHash = new HashMap();
|
|
|
|
|
|
for(Area a : p.getAreas())
|
|
|
{
|
|
|
areasHash.put(a.getId(), a);
|
|
|
for(Risco r : a.getRiscos())
|
|
|
{
|
|
|
riscosHash.put(r.getId(), r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
getSessionBean1().setAreasHash(areasHash);
|
|
|
getSessionBean1().setRiscosHash(riscosHash);
|
|
|
}
|
|
|
|
|
|
private void fillValoresHash(PlanoActuacao p)
|
|
|
{
|
|
|
//HashMap<Integer, Valor> valoresHash = new HashMap<Integer, Valor>();
|
|
|
HashMap<Integer, Risco> riscosHash = new HashMap<Integer, Risco>();
|
|
|
for(Area a : p.getAreas())
|
|
|
{
|
|
|
for(Risco r : a.getRiscos())
|
|
|
{
|
|
|
// for(Valor v : r.getValores())
|
|
|
// {
|
|
|
// valoresHash.put(v.getId(), v);
|
|
|
// }
|
|
|
riscosHash.put(r.getId(), r);
|
|
|
}
|
|
|
}
|
|
|
//getSessionBean1().setValoresHash(valoresHash);
|
|
|
getSessionBean1().setRiscosHash(riscosHash);
|
|
|
}
|
|
|
|
|
|
public void paginacao_actionListener(ActionEvent e)
|
|
|
{
|
|
|
Risco curValor = getSessionBean1().getCurrentRisco();
|
|
|
curValor = fillValorFields(curValor);
|
|
|
// getSessionBean1().getValoresHash().remove(curValor.getId());
|
|
|
// getSessionBean1().getValoresHash().put(curValor.getId(), curValor);
|
|
|
getSessionBean1().getRiscosHash().remove(curValor.getId());
|
|
|
getSessionBean1().getRiscosHash().put(curValor.getId(), curValor);
|
|
|
//gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
if(gridArea.getChildren() != null)
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
Pagina pagina = (Pagina) e.getSource();
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
// Valor v = pagination.getValor(pagina);
|
|
|
// v = getSessionBean1().getValoresHash().get(v.getId());
|
|
|
Risco r = pagination.getValor(pagina);
|
|
|
r = getSessionBean1().getRiscosHash().get(r.getId());
|
|
|
|
|
|
//Risco r = getSessionBean1().getRiscosHash().get(v.getRisco_id());
|
|
|
/////////Risco r = getSessionBean1().getRiscosHash().get(v.getRisco_id());
|
|
|
//Risco r = pagination.getRisco(pagina);
|
|
|
Area a = getSessionBean1().getAreasHash().get( r.getArea_id() );
|
|
|
showArea(a);
|
|
|
showRisco(r);
|
|
|
showValor(r);
|
|
|
showResponsavel(r);
|
|
|
}
|
|
|
|
|
|
public String butCancelar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return "lista_planos";
|
|
|
|
|
|
}
|
|
|
|
|
|
public String butLimparDados_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel");
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
TextField txtResponsavel = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtResponsavel");
|
|
|
TextArea txtRecursos = (TextArea) gridResponsavel.findComponent("form1:txtRecursos");
|
|
|
Calendar dtInicio = (Calendar) gridResponsavel.findComponent("form1:dtInicio:");
|
|
|
Calendar dtFim = (Calendar) gridResponsavel.findComponent("form1:dtFim");
|
|
|
txtResponsavel.setText("");
|
|
|
txtRecursos.setText("");
|
|
|
dtInicio.setValue(null);
|
|
|
dtFim.setValue(null);
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
TextArea txtParecerDl = (TextArea) gridResponsavel.findComponent("form1:txtParecerDl");
|
|
|
txtParecerDl.setText("");
|
|
|
PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl");
|
|
|
txtObs.setText("");
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
TextArea txtParecerDns = (TextArea) gridResponsavel.findComponent("form1:txtParecerDns");
|
|
|
txtParecerDns.setText("");
|
|
|
pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns");
|
|
|
if(pg != null)
|
|
|
{
|
|
|
TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns");
|
|
|
txtObs.setText("");
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
TextArea txtVerificacaoSiprp = (TextArea) gridResponsavel.findComponent("form1:txtVerificacaoSiprp");
|
|
|
txtVerificacaoSiprp.setText("");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String butEnviarCorrecao_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
System.out.println("BUT ENVIAR CORRECAO");
|
|
|
return "enviar_correcao";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|