git-svn-id: https://svn.coded.pt/svn/SIPRP@2040 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Carlos Roque 11 years ago
parent 40fcb1e852
commit 81a1d75bc4

@ -17,6 +17,7 @@ import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.Update;
import com.evolute.utils.sql.expression.Par;
import com.evolute.utils.strings.StringPlainer;
import com.sun.webui.jsf.model.Option;
import db.data.siprp.outer.EstadoMedidasData;
import db.data.siprp.outer.PlanoAreasData;
import db.data.siprp.outer.PlanoMedidasData;
@ -24,6 +25,8 @@ import db.data.siprp.outer.PlanoPostosTrabalhoData;
import db.data.siprp.outer.PlanoRiscosData;
import db.data.siprp.outer.PlanoValoresQualitativosData;
import db.data.siprp.outer.PlanosActuacaoData;
import db.data.siprp_local.outer.EmpresasData;
import db.data.siprp_local.outer.EstabelecimentosData;
import db.entidades.Area;
import db.entidades.EstadoMedida;
import db.entidades.LinhaEstatistica;
@ -69,6 +72,84 @@ public class PlanosDataProvider extends GenericDataProvider
}
return INSTANCE;
}
public Option[] getEstabelecimentos( Integer selectedEmpresa ) throws Exception
{
Option[] options = null;
Expression where = new Field( db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL ).isDifferent( "y" );
if( selectedEmpresa != null )
{
where = where.and( new Field( EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( selectedEmpresa ) );
}
Select2 query = new Select2(
new String[] { db.data.siprp_local.outer.EstabelecimentosData.TABLENAME },
new Integer[] { },
new Expression[] {},
new String[] {
db.data.siprp_local.outer.EstabelecimentosData.ID_FULL, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL
},
where,
new String[] { db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL },
null, null, null );
Virtual2DArray array = getLocalExecuter().executeQuery( query );
if ( array != null )
{
options = new Option[ array.rowCount() + 1 ];
options[ 0 ] = new Option( "", "" );
for ( int i = 0; i < array.rowCount(); i++ )
{
Integer estabelecimentoID = array.get( i, 0 );
String estabelecimentoNome = array.get( i, 1 );
options[ ( i + 1 ) ] = new Option( estabelecimentoID, estabelecimentoNome );
}
}
return options;
}
public String getEstabelecimentoByID( Integer estabelecimentoID ) throws Exception
{
String estabelecimento = "";
db.data.siprp_local.outer.EstabelecimentosData estabelecimentoData = getLocalProvider().load( db.data.siprp_local.outer.EstabelecimentosData.class, estabelecimentoID, db.data.siprp_local.outer.EstabelecimentosData.ID, null );
if ( estabelecimentoData != null )
{
estabelecimento = estabelecimentoData.getNome();
}
return estabelecimento;
}
public Option[] getEmpresas( ) throws Exception
{
Option[] options = null;
Expression where = new Field( db.data.siprp_local.outer.EmpresasData.INACTIVO_FULL ).isDifferent( "y" )
.and( new Field( EmpresasData.ID_FULL ).in( new Integer[] { 142, 85, 219, 32 } ) );
Select2 query = new Select2(
new String[] { db.data.siprp_local.outer.EmpresasData.TABLENAME },
new Integer[] { },
new Expression[] {},
new String[] {
db.data.siprp_local.outer.EmpresasData.ID_FULL, EmpresasData.DESIGNACAO_SOCIAL_FULL
},
where,
new String[] { EmpresasData.DESIGNACAO_SOCIAL_FULL },
null, null, null );
Virtual2DArray array = getLocalExecuter().executeQuery( query );
if ( array != null )
{
options = new Option[ array.rowCount() ];
for ( int i = 0; i < array.rowCount(); i++ )
{
Integer empresaID = array.get( i, 0 );
String empresaNome = array.get( i, 1 );
options[i] = new Option( empresaID, empresaNome );
}
}
return options;
}
public void updatePlano( PlanoActuacao p ) throws Exception
{
@ -208,7 +289,8 @@ public class PlanosDataProvider extends GenericDataProvider
private enum SECTION { ACTIVOS, SEGUIMENTO, CONCLUIDOS }
private Select2 getExpression( SECTION section, Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
private Select2 getExpression( SECTION section, Utilizador u, String nome, Integer empresa, String estabelecimento,
String dataVisita, Integer ano )
{
Expression where = getWhereExpression( nome, estabelecimento, dataVisita );
Expression faseExpression = null;
@ -232,6 +314,12 @@ public class PlanosDataProvider extends GenericDataProvider
{
where = where.and( new Field( "EXTRACT( year FROM " + PlanosActuacaoData.DATA_VISITA_FULL + " )" ).isEqual( ano) );
}
if( empresa != null )
{
where = where.and( new Field( PlanosActuacaoData.EMPRESA_ID_FULL ).isEqual( empresa ) );
}
Select2 query = new Select2(
new String[] { PlanosActuacaoData.TABLENAME, PlanoAreasData.TABLENAME, PlanoRiscosData.TABLENAME },
new Integer[] { Select2.JOIN_INNER, Select2.JOIN_INNER },
@ -315,12 +403,13 @@ public class PlanosDataProvider extends GenericDataProvider
}
public List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
public List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, Integer empresa, String estabelecimento,
String dataVisita, Integer ano )
throws Exception
{
System.out.println( "\nPlanosDataProvider . searchPlanosActivos() : " );
Select2 query = getExpression( SECTION.ACTIVOS, u, nome, estabelecimento, dataVisita, ano );
Select2 query = getExpression( SECTION.ACTIVOS, u, nome, empresa, estabelecimento, dataVisita, ano );
System.out.println( "\tSQL : " + query );
Virtual2DArray array = getExecuter().executeQuery( query );
@ -328,24 +417,27 @@ public class PlanosDataProvider extends GenericDataProvider
}
public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, Integer empresa, String
estabelecimento, String dataVisita, Integer ano )
throws Exception
{
System.out.println( "\nPlanosDataProvider . searchPlanosSeguimento() : " );
Select2 query = getExpression( SECTION.SEGUIMENTO, u, nome, estabelecimento, dataVisita, ano );
Select2 query = getExpression( SECTION.SEGUIMENTO, u, nome, empresa, estabelecimento, dataVisita, ano );
System.out.println( "\tSQL : " + query );
Virtual2DArray array = getExecuter().executeQuery( query );
return getFullPlanos( array );
}
public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, Integer empresa, String
estabelecimento,
String dataVisita, Integer ano )
throws Exception
{
System.out.println( "\nPlanosDataProvider . searchPlanosConcluidos() : " );
Select2 query = getExpression( SECTION.CONCLUIDOS, u, nome, estabelecimento, dataVisita, ano );
Select2 query = getExpression( SECTION.CONCLUIDOS, u, nome, empresa, estabelecimento, dataVisita, ano );
System.out.println( "\tSQL : " + query );
Virtual2DArray array = getExecuter().executeQuery( query );
@ -946,7 +1038,9 @@ public class PlanosDataProvider extends GenericDataProvider
return linhas;
}
public List<LinhaEstatistica> getEstatisticaForEstabelecimentoIdAndDateInterval( Integer estabelecimentoId, Date dataInicio, Date dataFim )
public List<LinhaEstatistica> getEstatisticaForEstabelecimentoIdAndDateInterval( Integer empresa,
Integer estabelecimentoId,
Date dataInicio, Date dataFim )
throws Exception
{
Expression expr = null;
@ -954,6 +1048,12 @@ public class PlanosDataProvider extends GenericDataProvider
{
expr = new Field( PlanosActuacaoData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoId);
}
if( empresa != null )
{
expr = new Field( PlanosActuacaoData.EMPRESA_ID_FULL ).isEqual( empresa );
}
if( dataInicio != null )
{
Expression diExpr = new Field( PlanosActuacaoData.DATA_VISITA_FULL ).isGreaterOrEqual( dataInicio);

@ -15,6 +15,8 @@ import db.data.siprp.outer.EmpresasData;
import db.data.siprp.outer.UtilizadoresData;
import db.entidades.Utilizador;
import utils.Global;
import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
@ -155,13 +157,18 @@ public class UtilizadoresDataProvider extends GenericDataProvider
public Boolean isSiprp( Utilizador utilizador ) throws DBException
{
Select select = new Select2( EmpresasData.TABLENAME, new Field( EmpresasData.DESIGNACAO_SOCIAL_FULL ).isILike( "siprp%" )
.and( new Field( EmpresasData.ID_FULL ).isEqual( utilizador.getEmpresa_id() ) ), "1" );
.and( new Field( EmpresasData.ID_FULL ).isEqual( utilizador.getEmpresa_id() ) ), "1" );
Select outer = new Select( "select exists( " + select.toString() + " )" );
Select outer = new Select( MessageFormat.format( "select exists( {0} )", select.toString() ) );
Virtual2DArray array = getExecuter().executeQuery( outer );
return array.rowCount() > 0 ? ( Boolean ) array.get( 0, 1 ) : Boolean.FALSE;
Boolean result = Boolean.FALSE;
if( array.rowCount() > 0 )
{
result = array.get( 0, 0 );
}
return result;
}
}

@ -15,10 +15,14 @@ import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.model.Option;
import db.entidades.LinhaEstatistica;
import db.providers.PlanosDataProvider;
import utils.Global;
import utils.Utils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.FacesException;
import javax.faces.event.ValueChangeEvent;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
@ -83,7 +87,22 @@ public class Estatistica extends AbstractPageBean {
// *Note* - this logic should NOT be modified
try {
_init();
fillEstabelecimentosDrop();
siprp = getSessionBean1().isSiprp();
Utils.fillEmpresas( dropEmpresas );
if( !siprp )
{
Utils.fillEstabelecimentos( getSessionBean1().getCurrentUser().getEmpresa_id(), dropEstabelecimento );
dropEmpresas.setSelected( getSessionBean1().getCurrentUser().getEmpresa_id() );
}
else
{
Utils.fillEstabelecimentos( Global.AUCHAN, dropEstabelecimento );
dropEmpresas.setSelected( Global.AUCHAN );
}
} catch (Exception e) {
log("Estatistica Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
@ -222,6 +241,48 @@ public class Estatistica extends AbstractPageBean {
this.tableRowGroupEstatisticas = tableRowGroupEstatisticas;
}
private DropDown dropEmpresas = new DropDown();
public void setDropEmpresas( DropDown dropEmpresas )
{
this.dropEmpresas = dropEmpresas;
}
public void dropEmpresas_valueChangeListener( ValueChangeEvent event )
{
Integer _old;
Integer _new;
if( event.getNewValue() != null && event.getNewValue() instanceof Integer )
{
_new = ( Integer ) event.getNewValue();
_old = event.getOldValue() != null &&
event.getOldValue() instanceof Integer ? ( Integer ) event.getOldValue() : null;
if( _old == null || !_new.equals( _old ) )
{
Utils.fillEstabelecimentos( _new, dropEstabelecimento );
dropEstabelecimento.setSelected( null );
}
}
}
public DropDown getDropEmpresas()
{
return dropEmpresas;
}
private Boolean siprp = Boolean.FALSE;
public Boolean getSiprp()
{
return siprp;
}
public void setSiprp( Boolean siprp )
{
this.siprp = siprp;
}
public String buttonPesquisar_action()
{
System.out.println( "ACTION" );
@ -229,21 +290,33 @@ public class Estatistica extends AbstractPageBean {
try
{
Integer estabelecimentoId = null;
if ( dropEstabelecimento.getSelected() != null )
Integer selectedEmpresa;
if( dropEmpresas.getSelected() instanceof Integer )
{
selectedEmpresa = ( Integer ) dropEmpresas.getSelected();
}
else
{
String estabelecimento = ( String ) dropEstabelecimento.getSelected();
if ( estabelecimento != null )
{
try {
estabelecimentoId = Integer.parseInt( estabelecimento );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
selectedEmpresa = Utils.getSelectedID( dropEmpresas );
}
linhasEstatistica = PlanosDataProvider.getInstance().getEstatisticaForEstabelecimentoIdAndDateInterval( estabelecimentoId, calInicioDate, calFimDate );
if( selectedEmpresa == null )
{
selectedEmpresa = getSessionBean1().getCurrentUser().getEmpresa_id();
}
if( dropEstabelecimento.getSelected() instanceof Integer )
{
estabelecimentoId = ( Integer ) dropEstabelecimento.getSelected();
}
else
{
estabelecimentoId = Utils.getSelectedID( dropEstabelecimento );
}
linhasEstatistica = PlanosDataProvider.getInstance().getEstatisticaForEstabelecimentoIdAndDateInterval(
selectedEmpresa, estabelecimentoId, calInicioDate, calFimDate );
System.out.println( "LINHAS: " + linhasEstatistica.size() );
}
catch( Exception ex )

@ -486,6 +486,9 @@ public class ListaPlanos extends AbstractPageBean
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
siprp = getSessionBean1().isSiprp();
}
/**
@ -500,6 +503,138 @@ public class ListaPlanos extends AbstractPageBean
{
}
private Boolean siprp = Boolean.FALSE;
public Boolean getSiprp()
{
return siprp;
}
public void setSiprp( Boolean siprp )
{
this.siprp = siprp;
}
private DropDown dropEmpresasActuais = new DropDown();
public void setDropEmpresasActuais( DropDown dropEmpresasActuais )
{
this.dropEmpresasActuais = dropEmpresasActuais;
}
public void dropEmpresasActuais_valueChangeListener( ValueChangeEvent event )
{
Integer _old;
Integer _new;
if( event.getNewValue() != null && event.getNewValue() instanceof Integer )
{
_new = ( Integer ) event.getNewValue();
_old = event.getOldValue() != null &&
event.getOldValue() instanceof Integer ? ( Integer ) event.getOldValue() : null;
if( _old == null || !_new.equals( _old ) )
{
Utils.fillEstabelecimentos( _new, dropEstabelecimentosActuais );
dropEstabelecimentosActuais.setSelected( null );
}
}
}
public DropDown getDropEmpresasActuais()
{
return dropEmpresasActuais;
}
private DropDown dropEstabelecimentosActuais = new DropDown();
public DropDown getDropEstabelecimentosActuais()
{
return dropEstabelecimentosActuais;
}
public void setDropEstabelecimentosActuais( DropDown dropEstabelecimentos )
{
this.dropEstabelecimentosActuais = dropEstabelecimentos;
}
private DropDown dropEmpresasSeguimento = new DropDown();
public void setDropEmpresasSeguimento( DropDown dropEmpresasSeguimento )
{
this.dropEmpresasSeguimento = dropEmpresasSeguimento;
}
public void dropEmpresasSeguimento_valueChangeListener( ValueChangeEvent event )
{
Integer _old;
Integer _new;
if( event.getNewValue() != null && event.getNewValue() instanceof Integer )
{
_new = ( Integer ) event.getNewValue();
_old = event.getOldValue() != null &&
event.getOldValue() instanceof Integer ? ( Integer ) event.getOldValue() : null;
if( _old == null || !_new.equals( _old ) )
{
Utils.fillEstabelecimentos( _new, dropEstabelecimentosSeguimento );
dropEstabelecimentosSeguimento.setSelected( null );
}
}
}
public DropDown getDropEmpresasSeguimento()
{
return dropEmpresasSeguimento;
}
private DropDown dropEstabelecimentosSeguimento = new DropDown();
public DropDown getDropEstabelecimentosSeguimento()
{
return dropEstabelecimentosSeguimento;
}
public void setDropEstabelecimentosSeguimento( DropDown dropEstabelecimentos )
{
this.dropEstabelecimentosSeguimento = dropEstabelecimentos;
}
private DropDown dropEmpresasConclusao = new DropDown();
public void setDropEmpresasConclusao( DropDown dropEmpresasConclusao )
{
this.dropEmpresasConclusao = dropEmpresasConclusao;
}
public void dropEmpresasConclusao_valueChangeListener( ValueChangeEvent event )
{
Integer _old;
Integer _new;
if( event.getNewValue() != null && event.getNewValue() instanceof Integer )
{
_new = ( Integer ) event.getNewValue();
_old = event.getOldValue() != null &&
event.getOldValue() instanceof Integer ? ( Integer ) event.getOldValue() : null;
if( _old == null || !_new.equals( _old ) )
{
Utils.fillEstabelecimentos( _new, dropEstabelecimentosConclusao );
dropEstabelecimentosConclusao.setSelected( null );
}
}
}
public DropDown getDropEmpresasConclusao()
{
return dropEmpresasConclusao;
}
private DropDown dropEstabelecimentosConclusao = new DropDown();
public DropDown getDropEstabelecimentosConclusao()
{
return dropEstabelecimentosConclusao;
}
public void setDropEstabelecimentosConclusao( DropDown dropEstabelecimentos )
{
this.dropEstabelecimentosConclusao = dropEstabelecimentos;
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
@ -515,10 +650,30 @@ public class ListaPlanos extends AbstractPageBean
HttpServletRequest request = ( HttpServletRequest ) getExternalContext().getRequest();
String referer = request.getRequestURI();
String pageFrom = Utils.getPageFrom( referer );
if ( !pageFrom.matches( "FormMedico.jsp" )
|| dropCurrentYear.getItems() == null )
if ( !pageFrom.matches( "ListaPlanos.jsp" ) || dropCurrentYear.getItems() == null )
{
fillCurrentYearDrop();
Utils.fillEmpresas( dropEmpresasActuais, dropEmpresasSeguimento, dropEmpresasConclusao );
if( !siprp )
{
dropEmpresasActuais.setSelected( getSessionBean1().getCurrentUser().getEmpresa_id() );
dropEmpresasSeguimento.setSelected( getSessionBean1().getCurrentUser().getEmpresa_id() );
dropEmpresasConclusao.setSelected( getSessionBean1().getCurrentUser().getEmpresa_id() );
Utils.fillEstabelecimentos( getSessionBean1().getCurrentUser().getEmpresa_id(),
dropEstabelecimentosActuais, dropEstabelecimentosSeguimento, dropEstabelecimentosConclusao );
}
else
{
dropEmpresasActuais.setSelected( Global.AUCHAN );
dropEmpresasSeguimento.setSelected( Global.AUCHAN );
dropEmpresasConclusao.setSelected( Global.AUCHAN );
Utils.fillEstabelecimentos( Global.AUCHAN,
dropEstabelecimentosActuais, dropEstabelecimentosSeguimento, dropEstabelecimentosConclusao );
}
fillInitialForm();
}
}
@ -886,7 +1041,8 @@ public class ListaPlanos extends AbstractPageBean
}
private List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
private List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, Integer empresa, String
estabelecimento, String dataVisita, Integer ano )
{
List< PlanoActuacao > list = null;
try
@ -894,7 +1050,7 @@ public class ListaPlanos extends AbstractPageBean
if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.GESTOR && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH )
{
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
list = pdp.searchPlanosActivos( u, nome, estabelecimento, dataVisita, ano );
list = pdp.searchPlanosActivos( u, nome, empresa, estabelecimento, dataVisita, ano );
}
}
catch ( Exception e )
@ -906,16 +1062,17 @@ public class ListaPlanos extends AbstractPageBean
private List<PlanoActuacao> getPlanosActivos( Utilizador u, Integer ano )
{
return searchPlanosActivos( u, null, null, null, ano );
return searchPlanosActivos( u, null, u.getEmpresa_id(), null, null, ano );
}
private List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
private List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, Integer empresa,
String estabelecimento, String dataVisita, Integer ano )
{
List< PlanoActuacao > list = null;
try
{
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
list = pdp.searchPlanosSeguimento( u, nome, estabelecimento, dataVisita, ano );
list = pdp.searchPlanosSeguimento( u, nome, empresa, estabelecimento, dataVisita, ano );
}
catch ( Exception ex )
{
@ -926,16 +1083,17 @@ public class ListaPlanos extends AbstractPageBean
private List< PlanoActuacao > getPlanosSeguimento( Utilizador u, Integer ano )
{
return searchPlanosSeguimento( u, null, null, null, ano );
return searchPlanosSeguimento( u, null, u.getEmpresa_id(), null, null, ano );
}
private List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
private List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, Integer empresa,
String estabelecimento, String dataVisita, Integer ano )
{
List< PlanoActuacao > list = null;
try
{
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
list = pdp.searchPlanosConcluidos( u, nome, estabelecimento, dataVisita, ano );
list = pdp.searchPlanosConcluidos( u, nome, empresa, estabelecimento, dataVisita, ano );
}
catch ( Exception ex )
{
@ -946,7 +1104,7 @@ public class ListaPlanos extends AbstractPageBean
private List< PlanoActuacao > getPlanosConcluidos( Utilizador u, Integer ano )
{
return searchPlanosConcluidos( u, null, null, null, ano );
return searchPlanosConcluidos( u, null, u.getEmpresa_id(), null, null, ano );
}
public String buttonFilterActual_action()
@ -962,13 +1120,39 @@ public class ListaPlanos extends AbstractPageBean
}
String estabelecimento = null;
if ( textFilterEstabelecimentoActual.getText() != null )
Integer selectedEmpresa;
if( dropEmpresasActuais.getSelected() instanceof Integer )
{
estabelecimento = ( ( String ) textFilterEstabelecimentoActual.getText() ).trim();
if ( estabelecimento.length() == 0 )
{
estabelecimento = null;
}
selectedEmpresa = ( Integer ) dropEmpresasActuais.getSelected();
}
else
{
selectedEmpresa = Utils.getSelectedID( dropEmpresasActuais );
}
if( selectedEmpresa == null )
{
selectedEmpresa = getSessionBean1().getCurrentUser().getEmpresa_id();
}
Integer estabelecimentoID;
if( dropEstabelecimentosActuais.getSelected() instanceof Integer )
{
estabelecimentoID = ( Integer ) dropEstabelecimentosActuais.getSelected();
}
else
{
estabelecimentoID = Utils.getSelectedID( dropEstabelecimentosActuais );
}
try
{
estabelecimento = PlanosDataProvider.getInstance().getEstabelecimentoByID( estabelecimentoID );
}
catch( Exception e )
{
ErrorLogger.logException( e );
}
String visitaDateStr = calFilterDate == null ? null : D_F.format( calFilterDate );
@ -977,7 +1161,8 @@ public class ListaPlanos extends AbstractPageBean
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
getSessionBean1().getPlanosActualDataProvider().setList(
searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, selectedEmpresa, estabelecimento, visitaDateStr,
ano ) );
return null;
}
@ -995,13 +1180,39 @@ public class ListaPlanos extends AbstractPageBean
}
String estabelecimento = null;
if ( textFilterEstabelecimentoSeg.getText() != null )
Integer selectedEmpresa;
if( dropEmpresasSeguimento.getSelected() instanceof Integer )
{
estabelecimento = ( ( String ) textFilterEstabelecimentoSeg.getText() ).trim();
if ( estabelecimento.length() == 0 )
{
estabelecimento = null;
}
selectedEmpresa = ( Integer ) dropEmpresasSeguimento.getSelected();
}
else
{
selectedEmpresa = Utils.getSelectedID( dropEmpresasSeguimento );
}
if( selectedEmpresa == null )
{
selectedEmpresa = getSessionBean1().getCurrentUser().getEmpresa_id();
}
Integer estabelecimentoID;
if( dropEstabelecimentosSeguimento.getSelected() instanceof Integer )
{
estabelecimentoID = ( Integer ) dropEstabelecimentosSeguimento.getSelected();
}
else
{
estabelecimentoID = Utils.getSelectedID( dropEstabelecimentosSeguimento );
}
try
{
estabelecimento = PlanosDataProvider.getInstance().getEstabelecimentoByID( estabelecimentoID );
}
catch( Exception e )
{
ErrorLogger.logException( e );
}
String visitaDateStr = calFilterDateSeguimento == null ? null : D_F.format( calFilterDateSeguimento );
@ -1010,7 +1221,8 @@ public class ListaPlanos extends AbstractPageBean
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
getSessionBean1().getPlanosSeguimentoDataProvider().setList(
searchPlanosSeguimento( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
searchPlanosSeguimento( getSessionBean1().getCurrentUser(), nome, selectedEmpresa, estabelecimento,
visitaDateStr, ano ) );
return null;
}
@ -1028,13 +1240,39 @@ public class ListaPlanos extends AbstractPageBean
}
String estabelecimento = null;
if ( textFilterEstabelecimentoConc.getText() != null )
Integer selectedEmpresa;
if( dropEmpresasConclusao.getSelected() instanceof Integer )
{
estabelecimento = ( ( String ) textFilterEstabelecimentoConc.getText() ).trim();
if ( estabelecimento.length() == 0 )
{
estabelecimento = null;
}
selectedEmpresa = ( Integer ) dropEmpresasConclusao.getSelected();
}
else
{
selectedEmpresa = Utils.getSelectedID( dropEmpresasConclusao );
}
if( selectedEmpresa == null )
{
selectedEmpresa = getSessionBean1().getCurrentUser().getEmpresa_id();
}
Integer estabelecimentoID;
if( dropEstabelecimentosConclusao.getSelected() instanceof Integer )
{
estabelecimentoID = ( Integer ) dropEstabelecimentosConclusao.getSelected();
}
else
{
estabelecimentoID = Utils.getSelectedID( dropEstabelecimentosConclusao );
}
try
{
estabelecimento = PlanosDataProvider.getInstance().getEstabelecimentoByID( estabelecimentoID );
}
catch( Exception e )
{
ErrorLogger.logException( e );
}
String visitaDateStr = calFilterDateConcluidos == null ? null : D_F.format( calFilterDateConcluidos );
@ -1043,7 +1281,8 @@ public class ListaPlanos extends AbstractPageBean
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
getSessionBean1().getPlanosConcluidosDataProvider().setList(
searchPlanosConcluidos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
searchPlanosConcluidos( getSessionBean1().getCurrentUser(), nome, selectedEmpresa, estabelecimento,
visitaDateStr, ano ) );
return null;
}

@ -231,6 +231,8 @@ public class Login extends AbstractPageBean
getSessionBean1().setCurrentUser( u );
getSessionBean1().setLoggedIn( true );
getSessionBean1().setSiprp( udp.isSiprp( u ) );
sRet = "lista_planos";
}
}

@ -482,4 +482,16 @@ public class SessionBean1 extends AbstractSessionBean {
this.anoChoice = anoChoice;
}
private Boolean siprp;
public Boolean isSiprp()
{
return siprp;
}
public void setSiprp( Boolean siprp )
{
this.siprp = siprp;
}
}

@ -49,8 +49,9 @@ public class Global
// public static final String ANALISE_ACIDENTES_URL = "http://localhost:8084/AnaliseAcidentesTrabalho/faces/"; //testes
// public static final String PLANOS_ACTUACAO_URL = "http://localhost:8084/PlanosActuacao/faces/"; //testes
// public static final String ANALISE_ACIDENTES_URL = "http://192.168.111.24:8084/AnaliseAcidentesTrabalho/faces/"; //testes portatil
public static final String ANALISE_ACIDENTES_URL = "https://www.siprp.pt/AnaliseAcidentesTrabalho/faces/"; //real
public static final String PLANOS_ACTUACAO_URL = "https://www.siprp.pt/PlanosActuacao/faces/";
//public static final String ANALISE_ACIDENTES_URL = "https://www.siprp.pt/AnaliseAcidentesTrabalho/faces/"; //real
public static final String ANALISE_ACIDENTES_URL = "http://localhost:8080/PlanosActuacao/faces/";
public static final String PLANOS_ACTUACAO_URL = "http://localhost:8080/PlanosActuacao/faces/";
public static final String LOGOS_FOLDER = "/resources/images";
public static final String PDF_FOLDER_URL = "/resources/pdf";
@ -65,4 +66,5 @@ public class Global
public static final String VALOR_INDETERMINADO = "IND";
public static final int AUCHAN = 32;
}

@ -7,6 +7,7 @@ package utils;
import com.evolute.utils.Singleton;
import com.evolute.utils.error.ErrorLogger;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.model.Option;
import db.entidades.Utilizador;
import db.providers.PlanosDataProvider;
@ -169,5 +170,82 @@ public class Utils
{
String pageFrom = referer.substring(referer.lastIndexOf("/")+1);
return pageFrom;
}
}
public static void fillEstabelecimentos( Integer empresaId, DropDown... drops )
{
try
{
Option[] estabelecimentos = PlanosDataProvider.getInstance().getEstabelecimentos( empresaId );
if ( estabelecimentos != null )
{
Integer selected = null;
for ( DropDown drop : drops )
{
if( drop.getSelected() != null )
{
if( drop.getSelected() instanceof Integer )
{
selected = ( Integer ) drop.getSelected();
}
else
{
selected = getSelectedID( drop );
}
}
drop.setItems( estabelecimentos );
drop.setSelected( selected );
}
}
}
catch ( Exception e )
{
ErrorLogger.logException( e );
}
}
public static Integer getSelectedID( DropDown drop )
{
Integer selectedID = null;
if ( drop.getSelected() != null )
{
String value = ( String ) drop.getSelected();
try { selectedID = Integer.parseInt( value ); }
catch ( Exception ignored ) { }
}
return selectedID;
}
public static void fillEmpresas( DropDown ... drops )
{
try
{
Option[] empresas = PlanosDataProvider.getInstance().getEmpresas();
if ( empresas != null )
{
Integer selected = null;
for ( DropDown drop : drops )
{
if( drop.getSelected() != null )
{
if( drop.getSelected() instanceof Integer )
{
selected = ( Integer ) drop.getSelected();
}
else
{
selected = getSelectedID( drop );
}
}
drop.setItems( empresas );
drop.setSelected( selected );
}
}
}
catch ( Exception e )
{
ErrorLogger.logException( e );
}
}
}

@ -22,6 +22,14 @@
<webuijsf:staticText id="labelEstatistica" style="font-size: 18px; font-weight: bold; height: 24px;" text="Estatisticas" />
</h:panelGrid>
<webuijsf:form id="formEstatistica">
<h:panelGrid columnClasses="gridColCenter" columns="1" id="panelGroup22"
style="height: 24px; width: 50%" styleClass="centerBlock" rendered="#{Estatistica.siprp}">
<webuijsf:staticText id="labelFilterEmpresas" text="Empresa:" />
<webuijsf:dropDown binding="#{Estatistica.dropEmpresas}" id="dropEmpresas"
valueChangeListenerExpression="#{Estatistica.dropEmpresas_valueChangeListener}"
onChange="webui.suntheme4_2.common.timeoutSubmitForm(this.form,
'gridBaseLayout:panelGroup22:dropEmpresas');"/>
</h:panelGrid>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridPanelEstabelecimento" style="height: 24px; width: 50%" styleClass="centerBlock">
<webuijsf:panelGroup>
<webuijsf:staticText escape="false" id="textEstabelecimento" text="Estabelecimento: " />

@ -1,17 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Document : ListaPlanos
Created on : Aug 29, 2008, 2:57:16 PM
Author : lluis
-->
<jsp:root version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:webuijsf="http://www.sun.com/webui/webuijsf"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:t="http://myfaces.apache.org/tomahawk">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
@ -23,7 +15,7 @@
<script type="text/javascript">
function alertOnDeactivate()
{
return confirm( 'Tem a certeza que pretende desactivar o plano ?\nEsta acção é irreversível e passará o plano para o estado Concluído.' );
return confirm( 'Tem a certeza que pretende desactivar o plano ?\nEsta ac<EFBFBD><EFBFBD>o <20> irrevers<72>vel e passar<61> o plano para o estado Conclu<6C>do.' );
}
</script>
</webuijsf:head>
@ -53,7 +45,7 @@
<h:panelGrid binding="#{ListaPlanos.gridActual}" columnClasses="gridColCenter" columns="1" id="gridActual"
style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText id="staticText1" style="font-size: 18px" text="Actual"/>
<webuijsf:staticText escape="false" id="staticText2" style="font-size: 14px" text=" "/>
<webuijsf:staticText escape="false" id="staticText2" style="font-size: 14px" text="&#160;"/>
<webuijsf:staticText id="staticText3" styleClass="label" text="Processos com dados pendentes"/>
<webuijsf:form id="form1">
@ -62,9 +54,21 @@
<webuijsf:staticText id="labelFilterNameActual" style="" text="Nome:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterNameActual}" id="textFilterNameActual" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentoActual" style="" text="Estabelecimento:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterEstabelecimentoActual}" id="textFilterEstabelecimentoActual" />
<webuijsf:panelGroup id="panelGroup21" rendered="#{ListaPlanos.siprp}">
<webuijsf:staticText id="labelFilterEmpresasActuais" text="Empresa:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEmpresasActuais}" id="dropEmpresasActuais"
valueChangeListenerExpression="#{ListaPlanos.dropEmpresasActuais_valueChangeListener}"
onChange="webui.suntheme4_2.common.timeoutSubmitForm(this.form,
'gridBaseLayout:gridLayout:gridActual:gridPanelFilterActual:panelGroup21:dropEmpresasActuais');"
style="height: 18px; width: 200px" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentosActuais" text="Estabelecimento:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEstabelecimentosActuais}"
id="dropEstabelecimentosActuais" style="height: 18px; width: 200px" />
<!-- <webuijsf:staticText id="labelFilterEstabelecimentoActual" style="" text="Estabelecimento:" /> -->
<!-- <webuijsf:textField binding="{ListaPlanos.textFilterEstabelecimentoActual}"
id="textFilterEstabelecimentoActual" /> -->
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterDateActual" text="Data da Visita:" />
@ -86,7 +90,7 @@
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn1" sort="data_visita">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkDataActivo" text="#{currentRow.value['data_visita_str']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn2" sort="tecnicos_nomes">
<webuijsf:tableColumn headerText="T&#233;cnico de HST" id="tableColumn2" sort="tecnicos_nomes">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkTecnicoHsActivo" text="#{currentRow.value['tecnicos_nomes']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn3" sort="fase">
@ -120,7 +124,7 @@
<!-- grid seguimento -->
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridSeguimento1" style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText id="staticText7" style="font-size: 18px" text="Em seguimento"/>
<webuijsf:staticText escape="false" id="staticText8" style="font-size: 14px" text=" "/>
<webuijsf:staticText escape="false" id="staticText8" style="font-size: 14px" text="&#160;"/>
<webuijsf:form id="form3">
@ -129,9 +133,21 @@
<webuijsf:staticText id="labelFilterNameSeg" style="" text="Nome:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterNameSeg}" id="textFilterNameSeg" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentoSeg" style="" text="Estabelecimento:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterEstabelecimentoSeg}" id="textFilterEstabelecimentoSeg" />
<webuijsf:panelGroup id="panelGroup22" rendered="#{ListaPlanos.siprp}">
<webuijsf:staticText id="labelFilterEmpresasSeguimento" text="Empresa:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEmpresasSeguimento}" id="dropEmpresasSeguimento"
valueChangeListenerExpression="#{ListaPlanos.dropEmpresasSeguimento_valueChangeListener}"
onChange="webui.suntheme4_2.common.timeoutSubmitForm(this.form,
'gridBaseLayout:gridLayout:gridSeguimento1:gridPanelFilterSeg:panelGroup22:dropEmpresasSeguimento');"
style="height: 18px; width: 200px" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentosSeguimento" text="Estabelecimento:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEstabelecimentosSeguimento}"
id="dropEstabelecimentosSeguimento" style="height: 18px; width: 200px" />
<!-- <webuijsf:staticText id="labelFilterEstabelecimentoSeg" style="" text="Estabelecimento:" /> -->
<!-- <webuijsf:textField binding="{ListaPlanos.textFilterEstabelecimentoSeg}"
id="textFilterEstabelecimentoSeg" /> -->
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterDateSeg" text="Data da Visita:" />
@ -152,7 +168,7 @@
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn4" sort="data_visita_str">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goVerPlanoFromSeguimento_action}" id="hyperlink1" text="#{currentRow.value['data_visita_str']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn5" sort="tecnicos_nomes">
<webuijsf:tableColumn headerText="T&#233;cnico de HST" id="tableColumn5" sort="tecnicos_nomes">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goVerPlanoFromSeguimento_action}" id="hyperlink2" text="#{currentRow.value['tecnicos_nomes']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn6" sort="fase_nome">
@ -185,7 +201,7 @@
<!-- grid concluidos -->
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridConcluidos" style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText escape="false" id="staticText14" style="font-size: 18px" text="Conclu&amp;iacute;dos"/>
<webuijsf:staticText escape="false" id="staticText15" style="font-size: 14px" text=" "/>
<webuijsf:staticText escape="false" id="staticText15" style="font-size: 14px" text="&#160;"/>
<webuijsf:form id="form5">
@ -194,9 +210,21 @@
<webuijsf:staticText id="labelFilterNameConc" style="" text="Nome:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterNameConc}" id="textFilterNameConc" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentoConc" style="" text="Estabelecimento:" />
<webuijsf:textField binding="#{ListaPlanos.textFilterEstabelecimentoConc}" id="textFilterEstabelecimentoConc" />
<webuijsf:panelGroup id="panelGroup23" rendered="#{ListaPlanos.siprp}">
<webuijsf:staticText id="labelFilterEmpresasConclusao" text="Empresa:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEmpresasConclusao}" id="dropEmpresasConclusao"
valueChangeListenerExpression="#{ListaPlanos.dropEmpresasConclusao_valueChangeListener}"
onChange="webui.suntheme4_2.common.timeoutSubmitForm(this.form,
'gridBaseLayout:gridLayout:gridConcluidos:gridPanelFilterConc:panelGroup23:dropEmpresasConclusao');"
style="height: 18px; width: 200px" />
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterEstabelecimentosConclusao" text="Estabelecimento:" />
<webuijsf:dropDown binding="#{ListaPlanos.dropEstabelecimentosConclusao}"
id="dropEstabelecimentosConclusao" style="height: 18px; width: 200px" />
<!-- <webuijsf:staticText id="labelFilterEstabelecimentoConc" style="" text="Estabelecimento:" /> -->
<!-- <webuijsf:textField binding="{ListaPlanos.textFilterEstabelecimentoConc}"
id="textFilterEstabelecimentoConc" /> -->
</webuijsf:panelGroup>
<webuijsf:panelGroup>
<webuijsf:staticText id="labelFilterDateConc" text="Data da Visita:" />
@ -217,7 +245,7 @@
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn7" sort="data_visita_str">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goVerPlanoFromConcluidos_action}" id="hyperlink6" text="#{currentRow.value['data_visita_str']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn8" sort="tecnicos_nomes">
<webuijsf:tableColumn headerText="T&#233;cnico de HST" id="tableColumn8" sort="tecnicos_nomes">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goVerPlanoFromConcluidos_action}" id="hyperlink7" text="#{currentRow.value['tecnicos_nomes']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn9" sort="fase_nome">
@ -234,7 +262,7 @@
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goVerPlanoFromConcluidos_action}" id="hyperlink10" text="#{currentRow.value['nome_estabelecimento']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="" id="tableColumnConcluidos6" binding="#{ListaPlanos.tableColumnConcluidos6}">
<webuijsf:button id="btnPreencherVerificacao" text="Preencher Verificação"
<webuijsf:button id="btnPreencherVerificacao" text="Preencher Verifica&#231;&#227;o"
actionExpression="#{ListaPlanos.goPreencherVerificacao_action}" binding="#{ListaPlanos.buttonPreencherVerificacao}" />
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>

Loading…
Cancel
Save