|
|
/*
|
|
|
* PlanoActuacao.java
|
|
|
*
|
|
|
* Created on Aug 26, 2008, 3:10:59 PM
|
|
|
*/
|
|
|
|
|
|
package planosactuacao;
|
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
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.EstadoMedida;
|
|
|
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 db.providers.UtilizadoresLogic;
|
|
|
import global.Global;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
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 pagination.PaginationNormais;
|
|
|
import pagination.PaginationPatrimoniais;
|
|
|
import planosactuacao.SessionBean1.PAGINATION_ENUM;
|
|
|
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 Checkbox chkDesactivar = new Checkbox();
|
|
|
|
|
|
public Checkbox getChkDesactivar() {
|
|
|
return chkDesactivar;
|
|
|
}
|
|
|
|
|
|
public void setChkDesactivar( Checkbox c ) {
|
|
|
this.chkDesactivar = 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 )
|
|
|
{
|
|
|
ErrorLogger.logException( 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();
|
|
|
|
|
|
System.out.println( "\nEditarPlano . prerender() : " + p.getId() + "\n");
|
|
|
|
|
|
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
|
|
|
{
|
|
|
butEnviarCorrecao.setDisabled( false );
|
|
|
butEnviar.setDisabled( true );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ( gridPagination.getChildCount() > 0 )
|
|
|
{
|
|
|
gridPagination.getChildren().clear();
|
|
|
}
|
|
|
setPagination( PAGINATION_ENUM.NORMAL );
|
|
|
setPagination( PAGINATION_ENUM.PATRIMONIAIS );
|
|
|
|
|
|
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 )
|
|
|
{
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
|
|
|
Pagination paginationNormal = new PaginationNormais( p, u );
|
|
|
Pagination paginationPatrimoniais = new PaginationPatrimoniais( p, u );
|
|
|
getSessionBean1().addPagination( PAGINATION_ENUM.NORMAL, paginationNormal );
|
|
|
getSessionBean1().addPagination( PAGINATION_ENUM.PATRIMONIAIS, paginationPatrimoniais );
|
|
|
|
|
|
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" );
|
|
|
}
|
|
|
|
|
|
if ( u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.TECNICO_HS )
|
|
|
{
|
|
|
gridValidar.setRendered( false );
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA )
|
|
|
// {
|
|
|
//
|
|
|
// }
|
|
|
// else if ( u.getTipo().intValue() == Global.DIRECTOR_LOJA || u.getTipo().intValue() == Global.TECNICO_HS )
|
|
|
// {
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
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 ) );
|
|
|
butEnviarCorrecao.setDisabled( true );
|
|
|
butEnviar.setDisabled( false );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
butEnviarCorrecao.setDisabled( false );
|
|
|
butEnviar.setDisabled( true );
|
|
|
}
|
|
|
butEnviar.setText( "Enviar a Director Nacional Seguran<61>a>>" );
|
|
|
|
|
|
if ( p.getCorrecao().matches( "y" ) )
|
|
|
{
|
|
|
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 ) );
|
|
|
butEnviarCorrecao.setDisabled( true );
|
|
|
butEnviar.setDisabled( false );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
butEnviarCorrecao.setDisabled( false );
|
|
|
butEnviar.setDisabled( true );
|
|
|
}
|
|
|
|
|
|
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 );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ( p.getValidacao_hs().booleanValue() == true )
|
|
|
{
|
|
|
chkValidacao.setSelected( new Boolean( true ) );
|
|
|
butEnviar.setDisabled( false );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
butEnviar.setDisabled( true );
|
|
|
}
|
|
|
butEnviar.setText( "Concluir" );
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
chkDesactivar.setSelected( Boolean.FALSE );
|
|
|
gridLayout.getChildren().add( gridPlano );
|
|
|
}
|
|
|
|
|
|
private void showPlano( PlanoActuacao p )
|
|
|
{
|
|
|
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 );
|
|
|
showValor( r );
|
|
|
showResponsavel( r );
|
|
|
}
|
|
|
}
|
|
|
showPreviousValidacoes( p );
|
|
|
|
|
|
Utilizador currentUser = getSessionBean1().getCurrentUser();
|
|
|
if ( currentUser.getTipo().intValue() == Global.TECNICO_HS
|
|
|
|| currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP )
|
|
|
{
|
|
|
chkDesactivar.setId( "chkDesactivarPlano" );
|
|
|
chkDesactivar.setLabel( "Desactivar Plano" );
|
|
|
chkDesactivar.setSelected( p.getConcluidoPorDesactivacao() );
|
|
|
chkDesactivar.setStyle( "float: left;" );
|
|
|
gridPlano.getChildren().add( chkDesactivar );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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 )
|
|
|
{
|
|
|
System.out.println( "\nEditarPlano . showRisco() : " + r.getId() + " - " + r.getDescricao() );
|
|
|
|
|
|
getSessionBean1().setCurrentRisco( r );
|
|
|
|
|
|
String riscoText = "Risco" + ( r.getIsPatrimonial() ? " Patrimonial: " : ": " );
|
|
|
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns( 1 );
|
|
|
grd.setWidth( "100%" );
|
|
|
|
|
|
gridRisco = new HtmlPanelGrid();
|
|
|
gridRisco.setWidth( "98%" );
|
|
|
gridRisco.setColumns( 1 );
|
|
|
gridRisco.setColumnClasses( "gridColLeft" );
|
|
|
gridArea.getChildren().add( gridRisco );
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setStyleClass( "label" );
|
|
|
st.setText( riscoText );
|
|
|
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%");
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridRisco.getChildren().add(gridValor);
|
|
|
gridValor.setWidth("100%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
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(Risco r)
|
|
|
{
|
|
|
getSessionBean1().setCurrentRisco(r);
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setColumnClasses("gridColLeft");
|
|
|
grd.setWidth("100%");
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridRisco.getChildren().add(gridValor);
|
|
|
gridValor.setWidth("100%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
|
|
|
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("IND");
|
|
|
}
|
|
|
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.setId( "gridMedida_" + m.getId() );
|
|
|
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 );
|
|
|
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao();
|
|
|
if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO )
|
|
|
{
|
|
|
List< EstadoMedida > opts = null;
|
|
|
try
|
|
|
{
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
opts = pdp.getEstadoMedidas();
|
|
|
}
|
|
|
catch ( Exception e )
|
|
|
{
|
|
|
ErrorLogger.logException( e );
|
|
|
}
|
|
|
|
|
|
DropDown drop = new DropDown();
|
|
|
Option opt[] = null;
|
|
|
if ( opts != null )
|
|
|
{
|
|
|
opt = new Option[ (opts.size() + 1) ];
|
|
|
opt[ 0 ] = new Option( 0, "" );
|
|
|
for ( int i = 0; i < opts.size(); i++ )
|
|
|
{
|
|
|
EstadoMedida em = opts.get( i );
|
|
|
opt[ (i+1) ] = new Option( em.getId(), em.getDescricao() );
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
opt = new Option[ 1 ];
|
|
|
opt[ 0 ] = new Option( 0, "" );
|
|
|
}
|
|
|
drop.setItems( opt );
|
|
|
|
|
|
drop.setId( "drop_" + r.getId() + "_" + m.getId() );
|
|
|
drop.setSelected( m.getValidarMedidaId() == null ? 0 : m.getValidarMedidaId() );
|
|
|
|
|
|
StaticText dropLabel = new StaticText();
|
|
|
dropLabel.setText( "Validar Medida: " );
|
|
|
|
|
|
PanelGroup valPG = new PanelGroup();
|
|
|
valPG.setId( "valPG_" + m.getId() );
|
|
|
valPG.getChildren().add( dropLabel );
|
|
|
valPG.getChildren().add( drop );
|
|
|
gridMedida.getChildren().add( valPG );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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( 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() );
|
|
|
pg.getChildren().add( st );
|
|
|
}
|
|
|
|
|
|
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 );
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( r.getParecer_dl() );
|
|
|
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 );
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( r.getParecer_dns() );
|
|
|
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 );
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( r.getVerificacao_siprp() );
|
|
|
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 )
|
|
|
{
|
|
|
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 );
|
|
|
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID( p.getUser_dir_loja() );
|
|
|
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 );
|
|
|
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID( p.getUser_dir_loja() );
|
|
|
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 );
|
|
|
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID( p.getUser_dns() );
|
|
|
st.setText( "Validado por " + nome + " (Director Nacional de Segurança) a " + p.getData_validacao_dns_str() );
|
|
|
gridValidacoes.getChildren().add( st );
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static final int MAX_PAGES_PER_LINE = 20;
|
|
|
|
|
|
private void setPagination( PAGINATION_ENUM type )
|
|
|
{
|
|
|
Class[] argtypes = new Class[ 1 ];
|
|
|
argtypes[ 0 ] = ActionEvent.class;
|
|
|
MethodExpression me = ( MethodExpression ) this.getApplication().getExpressionFactory().createMethodExpression(
|
|
|
getFacesContext().getELContext(), "#{EditarPlano.paginacao_actionListener}", null, argtypes );
|
|
|
|
|
|
StaticText typeLabel = new StaticText();
|
|
|
typeLabel.setText( type.getType() + ":" );
|
|
|
gridPagination.getChildren().add( typeLabel );
|
|
|
|
|
|
PanelGroup group = new PanelGroup();
|
|
|
|
|
|
Risco currentRisco = getSessionBean1().getCurrentRisco();
|
|
|
Pagination pagination = getSessionBean1().getPagination( type );
|
|
|
List< Pagina > paginas = pagination.getPages( currentRisco );
|
|
|
|
|
|
for ( int p = 0; p < paginas.size(); p++ )
|
|
|
{
|
|
|
Pagina pagina = paginas.get( p );
|
|
|
|
|
|
if ( p > 0 && p % MAX_PAGES_PER_LINE == 0 )
|
|
|
{
|
|
|
gridPagination.getChildren().add( group );
|
|
|
group = new PanelGroup();
|
|
|
}
|
|
|
|
|
|
if ( pagina.isPrevious() )
|
|
|
{
|
|
|
pagina.addActionListener( new MethodExpressionActionListener( me ) );
|
|
|
pagina.setPaginationType( type );
|
|
|
group.getChildren().add( pagina );
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( " " );
|
|
|
group.getChildren().add( st );
|
|
|
}
|
|
|
else if ( pagina.isNext() )
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( " " );
|
|
|
group.getChildren().add( st );
|
|
|
pagina.addActionListener( new MethodExpressionActionListener( me ) );
|
|
|
pagina.setPaginationType( type );
|
|
|
group.getChildren().add( pagina );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pagina.addActionListener( new MethodExpressionActionListener( me ) );
|
|
|
pagina.setPaginationType( type );
|
|
|
group.getChildren().add( pagina );
|
|
|
if ( pagina.getPageNumber().intValue() < pagination.getTotalPages() )
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape( false );
|
|
|
st.setText( " | " );
|
|
|
group.getChildren().add( st );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
gridPagination.getChildren().add( group );
|
|
|
}
|
|
|
|
|
|
// 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()
|
|
|
{
|
|
|
String page = null;
|
|
|
try
|
|
|
{
|
|
|
page = gravarPlano();
|
|
|
getSessionBean1().setMsg("Os dados do Plano de Actuação foram guardados");
|
|
|
}
|
|
|
catch ( Exception ex )
|
|
|
{
|
|
|
ErrorLogger.logException( new Exception( "Erro na gravacao do plano!" ) );
|
|
|
ErrorLogger.logException( ex );
|
|
|
getSessionBean1().setMsg("Erro na gravação do plano!");
|
|
|
}
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
private String gravarPlano() throws Exception
|
|
|
{
|
|
|
String returnToPage = null;
|
|
|
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));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Utilizador currentUser = getSessionBean1().getCurrentUser();
|
|
|
if ( currentUser.getTipo().intValue() == Global.TECNICO_HS
|
|
|
|| currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP )
|
|
|
{
|
|
|
Checkbox chkD = ( Checkbox ) gridPlano.findComponent( "form1:chkDesactivarPlano" );
|
|
|
if ( chkD != null )
|
|
|
{
|
|
|
Boolean desactivar = ( Boolean ) chkD.getSelected();
|
|
|
if ( desactivar != null && desactivar )
|
|
|
{
|
|
|
p.setFase( Global.FASE_CONCLUIDO );
|
|
|
p.setConcluidoPorDesactivacao( Boolean.TRUE );
|
|
|
returnToPage = "lista_planos";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
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);
|
|
|
|
|
|
if ( fase == Global.FASE_SIPRP_CONCLUSAO )
|
|
|
{
|
|
|
pdp.updateMedidas( r );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return returnToPage;
|
|
|
}
|
|
|
|
|
|
public String butGravarRisco_action()
|
|
|
{
|
|
|
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
|
|
|
{
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
pdp.updatePlano( p );
|
|
|
}
|
|
|
catch ( Exception ex )
|
|
|
{
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
Risco r = getSessionBean1().getCurrentRisco();
|
|
|
r = fillValorFields( r );
|
|
|
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
pdp.updateRisco( r );
|
|
|
if ( fase == Global.FASE_SIPRP_CONCLUSAO )
|
|
|
{
|
|
|
pdp.updateMedidas( r );
|
|
|
}
|
|
|
getSessionBean1().getRiscosHash().remove( r.getId() );
|
|
|
getSessionBean1().getRiscosHash().put( r.getId(), r );
|
|
|
|
|
|
// Pagination pagination = getSessionBean1().getPagination();
|
|
|
Pagination pagination = getSessionBean1().getPagination( r.getIsPatrimonial() ? PAGINATION_ENUM.PATRIMONIAIS : PAGINATION_ENUM.NORMAL );
|
|
|
|
|
|
r = pagination.getNextRisco();
|
|
|
Area a = getSessionBean1().getAreasHash().get( r.getArea_id() );
|
|
|
if ( r != null )
|
|
|
{
|
|
|
gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" );
|
|
|
if ( gridArea.getChildren() != null )
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
showArea( a );
|
|
|
showRisco( r );
|
|
|
showValor( r );
|
|
|
showResponsavel( r );
|
|
|
}
|
|
|
}
|
|
|
catch ( Exception ex )
|
|
|
{
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao();
|
|
|
if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO )
|
|
|
{
|
|
|
for( Medida m: r.getMedidas() )
|
|
|
{
|
|
|
gridMedida = (HtmlPanelGrid) gridArea.findComponent("form1:gridMedida_" + m.getId() );
|
|
|
if ( gridMedida != null )
|
|
|
{
|
|
|
PanelGroup gridValPG = ( PanelGroup ) gridMedida.findComponent( "valPG_" + m.getId() );
|
|
|
if ( gridValPG != null )
|
|
|
{
|
|
|
DropDown drop = ( DropDown ) gridValPG.findComponent("drop_" + r.getId() + "_" + m.getId());
|
|
|
if( drop != null )
|
|
|
{
|
|
|
Integer optID = ( Integer ) drop.getSelected();
|
|
|
m.setValidarMedidaId( optID.intValue() == 0 ? null : optID );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
public String butEnviar_action()
|
|
|
{
|
|
|
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);
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
processEnviar(p);
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Erro no envio do Plano");
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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_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++;
|
|
|
}
|
|
|
}
|
|
|
if ( ok )
|
|
|
{
|
|
|
p.setData_validacao_seg( new Date() );
|
|
|
p.setUser_seg( getSessionBean1().getCurrentUser().getId() );
|
|
|
}
|
|
|
|
|
|
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() );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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));
|
|
|
p.setData_validacao_dir_loja( new Date() );
|
|
|
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 )
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
getSessionBean1().setMsg("É necess<73>rio validar o processo antes de dar seguimento para a fase seguinte!");
|
|
|
ok = false;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
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("");
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
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
|
|
|
{
|
|
|
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
|
|
|
List< Utilizador > 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)
|
|
|
{
|
|
|
ErrorLogger.logException( ex1 );
|
|
|
System.out.println("MAIL ERROR : " + ex1.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
}
|
|
|
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
|
|
|
{
|
|
|
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
|
|
|
List< Utilizador > 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)
|
|
|
{
|
|
|
ErrorLogger.logException( ex1 );
|
|
|
System.out.println("MAIL ERROR : " + ex1.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ErrorLogger.logException( ex );
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// catch(Exception ex)
|
|
|
// {
|
|
|
// //ErrorLogger.logException( ex );
|
|
|
// }
|
|
|
// Mail mail = new Mail();
|
|
|
// try
|
|
|
// {
|
|
|
// mail.send("lluis@evolute.pt", Mail.ENDERECO_ENVIO, assunto, mail_text);
|
|
|
// System.out.println("EMAIL ENVIADO !!");
|
|
|
// }
|
|
|
// catch(Exception ex)
|
|
|
// {
|
|
|
// ErrorLogger.logException( ex );
|
|
|
// 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, 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().getRiscosHash().remove( curValor.getId() );
|
|
|
getSessionBean1().getRiscosHash().put( curValor.getId(), curValor );
|
|
|
|
|
|
gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" );
|
|
|
if ( gridArea.getChildren() != null )
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
Pagina pagina = ( Pagina ) e.getSource();
|
|
|
PAGINATION_ENUM type = pagina.getPaginationType();
|
|
|
|
|
|
// Pagination pagination = getSessionBean1().getPagination();
|
|
|
Pagination pagination = getSessionBean1().getPagination( type );
|
|
|
if ( pagination != null )
|
|
|
{
|
|
|
Risco r = pagination.getRisco( pagina );
|
|
|
r = getSessionBean1().getRiscosHash().get( r.getId() );
|
|
|
|
|
|
Area a = getSessionBean1().getAreasHash().get( r.getArea_id() );
|
|
|
showArea( a );
|
|
|
showRisco( r );
|
|
|
showValor( r );
|
|
|
showResponsavel( r );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String butCancelar_action()
|
|
|
{
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
|
|
|
public String butLimparDados_action()
|
|
|
{
|
|
|
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()
|
|
|
{
|
|
|
System.out.println( "BUT ENVIAR CORRECAO" );
|
|
|
return "enviar_correcao";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|