|
|
/*
|
|
|
* 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.Button;
|
|
|
import com.sun.webui.jsf.component.Calendar;
|
|
|
import com.sun.webui.jsf.component.Checkbox;
|
|
|
import com.sun.webui.jsf.component.DropDown;
|
|
|
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 com.sun.webui.jsf.model.Option;
|
|
|
|
|
|
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 global.Global;
|
|
|
import java.util.List;
|
|
|
import java.util.Vector;
|
|
|
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.ValueChangeEvent;
|
|
|
import mail.Mail;
|
|
|
import utils.JSFUtils;
|
|
|
|
|
|
/**
|
|
|
* <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>
|
|
|
HtmlPanelGrid grid;
|
|
|
PanelGroup pg;
|
|
|
StaticText st;
|
|
|
private HtmlPanelGrid gridLayout = new HtmlPanelGrid();
|
|
|
|
|
|
//Plano actuacao
|
|
|
PlanoActuacao plano;
|
|
|
Vector<Medida> medidas = new Vector<Medida>();
|
|
|
Vector<Risco> riscos = new Vector<Risco>();
|
|
|
Vector<PostoTrabalho> postos = new Vector<PostoTrabalho>();
|
|
|
|
|
|
HtmlPanelGrid gridPlano = new HtmlPanelGrid();
|
|
|
HtmlPanelGrid gridArea;
|
|
|
HtmlPanelGrid gridRisco;
|
|
|
HtmlPanelGrid gridValor;
|
|
|
HtmlPanelGrid gridMedida;
|
|
|
HtmlPanelGrid gridPosto;
|
|
|
|
|
|
|
|
|
|
|
|
int risco_id = 0;
|
|
|
int medida_id = 0;
|
|
|
int posto_id = 0;
|
|
|
|
|
|
//page components
|
|
|
TextField txtResponsavelExecucao;
|
|
|
TextArea txtRecursos;
|
|
|
Calendar dtInicio;
|
|
|
Calendar dtFim;
|
|
|
|
|
|
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 HtmlPanelGrid gridParecer = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridParecer() {
|
|
|
return gridParecer;
|
|
|
}
|
|
|
|
|
|
public void setGridParecer(HtmlPanelGrid hpg) {
|
|
|
this.gridParecer = hpg;
|
|
|
}
|
|
|
private TextArea txtParecer = new TextArea();
|
|
|
|
|
|
public TextArea getTxtParecer() {
|
|
|
return txtParecer;
|
|
|
}
|
|
|
|
|
|
public void setTxtParecer(TextArea ta) {
|
|
|
this.txtParecer = ta;
|
|
|
}
|
|
|
private HtmlInputHidden hidValidacao = new HtmlInputHidden();
|
|
|
|
|
|
public HtmlInputHidden getHidValidacao() {
|
|
|
return hidValidacao;
|
|
|
}
|
|
|
|
|
|
public void setHidValidacao(HtmlInputHidden hih) {
|
|
|
this.hidValidacao = hih;
|
|
|
}
|
|
|
private StaticText stIrPara = new StaticText();
|
|
|
|
|
|
public StaticText getStIrPara() {
|
|
|
return stIrPara;
|
|
|
}
|
|
|
|
|
|
public void setStIrPara(StaticText st) {
|
|
|
this.stIrPara = st;
|
|
|
}
|
|
|
private DropDown drpIrPara = new DropDown();
|
|
|
|
|
|
public DropDown getDrpIrPara() {
|
|
|
return drpIrPara;
|
|
|
}
|
|
|
|
|
|
public void setDrpIrPara(DropDown dd) {
|
|
|
this.drpIrPara = dd;
|
|
|
}
|
|
|
private StaticText lblTop = new StaticText();
|
|
|
|
|
|
public StaticText getLblTop() {
|
|
|
return lblTop;
|
|
|
}
|
|
|
|
|
|
public void setLblTop(StaticText st) {
|
|
|
this.lblTop = 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)
|
|
|
{
|
|
|
stIrPara.setStyleClass("hidden");
|
|
|
drpIrPara.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);
|
|
|
if(!isPostback)
|
|
|
{
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
//initializePlano();
|
|
|
initialize(p);
|
|
|
showPlano(p);
|
|
|
//fillPlano();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
riscos = getSessionBean1().getRiscos();
|
|
|
medidas = getSessionBean1().getMedidas();
|
|
|
postos = getSessionBean1().getPostos();
|
|
|
}
|
|
|
|
|
|
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 fillPlano()
|
|
|
// {
|
|
|
// String indent = " ";
|
|
|
// Risco r = getNextRisco(plano.getId());
|
|
|
// fillRisco(r);
|
|
|
// }
|
|
|
//
|
|
|
// private void fillRisco(Risco r)
|
|
|
// {
|
|
|
// String indent = " ";
|
|
|
// if(gridLayout.getChildren().size() > 0)
|
|
|
// {
|
|
|
// gridLayout.getChildren().clear();
|
|
|
// }
|
|
|
// gridRisco = new HtmlPanelGrid();
|
|
|
// gridRisco.setWidth("100%");
|
|
|
// gridRisco.setStyle("border: solid 1px #000000");
|
|
|
// gridRisco.setColumns(1);
|
|
|
// gridRisco.setColumnClasses("gridColLeft");
|
|
|
//
|
|
|
// pg = new PanelGroup();
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setStyle("color: #2c4d7a");
|
|
|
// st.setText("RISCO 1" + ": ");
|
|
|
// pg.getChildren().add(st);
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setText(r.getDescricao());
|
|
|
// pg.getChildren().add(st);
|
|
|
// gridRisco.getChildren().add(pg);
|
|
|
//
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setText(" ");
|
|
|
// gridRisco.getChildren().add(st);
|
|
|
//
|
|
|
// 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(r.getValor().toString());
|
|
|
// pg.getChildren().add(st);
|
|
|
// gridRisco.getChildren().add(pg);
|
|
|
//
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setText(" ");
|
|
|
// gridRisco.getChildren().add(st);
|
|
|
//
|
|
|
// //medidas
|
|
|
// Vector<Medida> meds = getMedidas(r.getId());
|
|
|
// for(int i = 0; i < meds.size(); i++)
|
|
|
// {
|
|
|
// Medida m = medidas.get(i);
|
|
|
// if(m.getRisco_id().intValue() == r.getId().intValue())
|
|
|
// {
|
|
|
// pg = new PanelGroup();
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText(indent + "Medida" + ": ");
|
|
|
// pg.getChildren().add(st);
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setText(m.getDescricao());
|
|
|
// pg.getChildren().add(st);
|
|
|
// gridRisco.getChildren().add(pg);
|
|
|
//
|
|
|
// //postos trabalho
|
|
|
// Vector<PostoTrabalho> posts = getPostosTrabalho(m.getId());
|
|
|
// pg = new PanelGroup();
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText(indent + indent + "Postos de trabalho afectados" + ": ");
|
|
|
// pg.getChildren().add(st);
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// String spostos = "";
|
|
|
// for(int j = 0; j < posts.size(); j++)
|
|
|
// {
|
|
|
// PostoTrabalho p = posts.get(j);
|
|
|
// spostos += p.getDescricao(); // + " ";
|
|
|
// if(j < (posts.size() -1) )
|
|
|
// {
|
|
|
// spostos += "; ";
|
|
|
// }
|
|
|
// }
|
|
|
// st.setText(spostos);
|
|
|
// pg.getChildren().add(st);
|
|
|
// gridRisco.getChildren().add(pg);
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setText(" ");
|
|
|
// gridRisco.getChildren().add(st);
|
|
|
//
|
|
|
// pg = new PanelGroup();
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText("Responsável de execução:");
|
|
|
// pg.getChildren().add(st);
|
|
|
// txtResponsavelExecucao = new TextField();
|
|
|
// txtResponsavelExecucao.setColumns(100);
|
|
|
// pg.getChildren().add(txtResponsavelExecucao);
|
|
|
// gridRisco.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);
|
|
|
// gridRisco.getChildren().add(pg);
|
|
|
// txtRecursos = new TextArea();
|
|
|
// txtRecursos.setColumns(200);
|
|
|
// gridRisco.getChildren().add(txtRecursos);
|
|
|
//
|
|
|
// HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
// grd.setColumns(2);
|
|
|
// grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
// grd.setId("pgDtInicio");
|
|
|
// grd.setStyle("width: 100%");
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText("Data prevista de início:");
|
|
|
// grd.getChildren().add(st);
|
|
|
// dtInicio = new Calendar();
|
|
|
// grd.getChildren().add(dtInicio);
|
|
|
// gridRisco.getChildren().add(grd);
|
|
|
//
|
|
|
// grd = new HtmlPanelGrid();
|
|
|
// grd.setColumns(2);
|
|
|
// grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
// grd.setId("pgDtFim");
|
|
|
// grd.setStyle("width: 100%");
|
|
|
// st = new StaticText();
|
|
|
// st.setEscape(false);
|
|
|
// st.setStyleClass("label");
|
|
|
// st.setText("Data prevista de conclusão:");
|
|
|
// grd.getChildren().add(st);
|
|
|
// dtFim = new Calendar();
|
|
|
//
|
|
|
// grd.getChildren().add(dtFim);
|
|
|
// gridRisco.getChildren().add(grd);
|
|
|
//
|
|
|
// gridLayout.getChildren().add(gridRisco);
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// private Risco getNextRisco(Integer planoId)
|
|
|
// {
|
|
|
// System.out.println("GET NEXT RISCO");
|
|
|
// System.out.println("RISCOS SIZE : " + riscos.size());
|
|
|
// riscos = getSessionBean1().getRiscos();
|
|
|
// risco_id = getSessionBean1().getRiscosIdx();
|
|
|
// Risco r = riscos.get(risco_id);
|
|
|
// if(r != null)
|
|
|
// {
|
|
|
// if(r.getPlano_id().intValue() != planoId.intValue())
|
|
|
// {
|
|
|
// r = null;
|
|
|
// risco_id = 0;
|
|
|
// }
|
|
|
// }
|
|
|
// risco_id++;
|
|
|
// getSessionBean1().setRiscosIdx(risco_id);
|
|
|
// return r;
|
|
|
// }
|
|
|
|
|
|
// private Vector<Medida> getMedidas(Integer riscoId)
|
|
|
// {
|
|
|
// Vector<Medida> meds = new Vector<Medida>();
|
|
|
// medidas = getSessionBean1().getMedidas();
|
|
|
// for(int i = 0; i < medidas.size(); i++)
|
|
|
// {
|
|
|
// Medida m = medidas.get(i);
|
|
|
// if(m.getRisco_id().intValue() == riscoId.intValue())
|
|
|
// {
|
|
|
// meds.add(m);
|
|
|
// }
|
|
|
// }
|
|
|
// return meds;
|
|
|
// }
|
|
|
|
|
|
private Vector<PostoTrabalho> getPostosTrabalho(Integer medidaId)
|
|
|
{
|
|
|
Vector<PostoTrabalho> posts = new Vector<PostoTrabalho>();
|
|
|
postos = getSessionBean1().getPostos();
|
|
|
for(int i = 0; i < postos.size(); i++)
|
|
|
{
|
|
|
PostoTrabalho p = postos.get(i);
|
|
|
if(p.getMedida_id().intValue() == medidaId.intValue())
|
|
|
{
|
|
|
posts.add(p);
|
|
|
}
|
|
|
}
|
|
|
return posts;
|
|
|
}
|
|
|
|
|
|
private void initialize(PlanoActuacao p)
|
|
|
{
|
|
|
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");
|
|
|
}
|
|
|
|
|
|
//gridValidar.setStyleClass("hidden");
|
|
|
|
|
|
//System.out.println("VISIBILITY : " + gridValidar.getStyleClass());
|
|
|
//System.out.println("USER TYPE : " + u.getTipo().intValue());
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
//gridValidar.setStyleClass("visible");
|
|
|
//System.out.println("VISIBILITY B : " + gridValidar.getStyleClass());
|
|
|
gridValidar.setRendered(false);
|
|
|
//txtParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
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:
|
|
|
butEnviar.setText("Enviar a Director de Loja>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
//butEnviar.setText("Enviar a Director de Loja");
|
|
|
butEnviar.setText("Enviar para Respons<6E>vel de Seguran<61>a>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
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 Respons<6E>vel de seguran<61>a>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
butEnviar.setText("Concluir");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
gridArea = new HtmlPanelGrid();
|
|
|
gridArea.setColumns(1);
|
|
|
gridArea.setColumnClasses("gridColLeft");
|
|
|
gridArea.setWidth("100%");
|
|
|
gridArea.setStyle("border: solid 1px #000000");
|
|
|
gridPlano.getChildren().add(gridArea);
|
|
|
|
|
|
Area a = p.getAreas().get(0);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(a.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridArea.getChildren().add(pg);
|
|
|
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridArea.getChildren().add(grd);
|
|
|
|
|
|
//Risco
|
|
|
gridRisco = new HtmlPanelGrid();
|
|
|
gridRisco.setStyleClass("centerBlock");
|
|
|
gridRisco.setWidth("98%");
|
|
|
gridRisco.setColumns(1);
|
|
|
gridRisco.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridRisco);
|
|
|
|
|
|
Risco r = a.getRiscos().get(0);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
showValores(r);
|
|
|
|
|
|
|
|
|
gridMedida = new HtmlPanelGrid();
|
|
|
gridMedida.setStyleClass("centerBlock");
|
|
|
gridMedida.setWidth("98%");
|
|
|
gridMedida.setColumns(1);
|
|
|
gridMedida.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridMedida);
|
|
|
}
|
|
|
|
|
|
private void showValores(Risco r)
|
|
|
{
|
|
|
List<Valor> valores = r.getValores();
|
|
|
|
|
|
for(Valor v : valores)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridRisco.getChildren().add(grd);
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridValor.setStyleClass("centerBlock");
|
|
|
gridValor.setWidth("98%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridValor);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText("Valor : " + v.getValor().toString());
|
|
|
pg.getChildren().add(st);
|
|
|
gridValor.getChildren().add(pg);
|
|
|
|
|
|
showMedidas(v);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void showMedidas(Valor v)
|
|
|
{
|
|
|
List<Medida> medidas = v.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.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.setText(p.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridPosto.getChildren().add(pg);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String butGravarPlano_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String butGravarRisco_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
System.out.println("BUT NEXT RISCO");
|
|
|
//Risco r = getNextRisco(getSessionBean1().getPlanoId());
|
|
|
//fillRisco(r);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String butEnviar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
try
|
|
|
{
|
|
|
processEnviar();
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Erro no envio do Plano");
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private void processEnviar() throws Exception
|
|
|
{
|
|
|
boolean processo_validado = true;
|
|
|
int dns_next_fase = 2;
|
|
|
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
//dummy : later on get fase from plano
|
|
|
//int fase = getSessionBean1().getFase();
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
fase++;
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Integer irPara = (Integer)drpIrPara.getSelected();
|
|
|
dns_next_fase = irPara.intValue();
|
|
|
fase = dns_next_fase;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//dummy : later on will update db with new fase
|
|
|
//getSessionBean1().setFase(fase);
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
p.setFase(new Integer(fase));
|
|
|
pdp.updatePlano(p);
|
|
|
|
|
|
enviarMail(fase);
|
|
|
}
|
|
|
|
|
|
public void enviarMail(int fase)
|
|
|
{
|
|
|
String assunto = "";
|
|
|
String mail_text = "";
|
|
|
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
assunto = "PLANOS - SEGURAN<41>A (PREENCHIMENTO)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Seguran<61>a(Preenchimento)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
assunto = "PLANOS - DIRECTOR LOJA (VALIDA<44><41>O)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Director de Loja(Valida<64><61>o)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
assunto = "PLANOS - DNS (PARECER)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Dns(Parecer)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
assunto = "PLANOS - TSHS SIPRP (CONCLUS<55>O)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase TSHS(Conclus<75>o)";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(fase < Global.FASE_CONCLUIDO) // nao envia para ninguem na fase Concluido
|
|
|
{
|
|
|
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) {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|