();
-
- /** Creates a new instance of FichaDataProvider */
- private FichaDataProvider()
- throws Exception
- {
- DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
- executer = dbm.getSharedExecuter( this );
-
-// setDBTable( EXAMES );
-
- }
-
-// public static MetaProvider getProvider()
-// throws Exception
-// {
-// synchronized( LOCK )
-// {
-// if( instance == null )
-// {
-// instance = new FichaDataProvider();
-// }
-// }
-// return instance;
-// }
-
- public static FichaDataProvider getProvider()
- throws Exception
- {
- synchronized( LOCK )
- {
- if( instance == null )
- {
- instance = new FichaDataProvider();
- }
- }
- return instance;
- }
-
- public String[] getColumnNames() {
- return new String[]{ "Nome" };
- }
-
- public String getSearchTitle() {
- switch( SEARCH )
- {
- case SEARCH_EMPRESAS:
- return "Procurar empresa";
- case SEARCH_ESTABELECIMENTOS:
- return "Procurar estabelecimento";
- case SEARCH_TRABALHADORES:
- return "Procurar trabalhador";
- case SEARCH_EXAMES:
- return "Procurar exame";
- }
- return "";
- }
-
- public boolean hasDetails() {
- return false;
- }
-
- public void setSearch( int what )
- {
- switch( what )
- {
- case SEARCH_EMPRESAS:
- case SEARCH_ESTABELECIMENTOS:
- case SEARCH_TRABALHADORES:
- case SEARCH_EXAMES:
- SEARCH = what;
- break;
- }
- }
-
- public void setSearchID( int what, int id )
- {
- switch( what )
- {
- case SEARCH_EMPRESAS:
- SEARCH_EMPRESAS_ID = id;
- break;
- case SEARCH_ESTABELECIMENTOS:
- SEARCH_ESTABELECIMENTOS_ID = id;
- break;
- case SEARCH_TRABALHADORES:
- SEARCH_TRABALHADORES_ID = id;
- break;
- case SEARCH_EXAMES:
- SEARCH_EXAMES_ID = id;
- break;
- }
- }
-
- public Virtual2DArray search( String pattern ) throws Exception {
- switch( SEARCH )
- {
- case SEARCH_EMPRESAS:
- return searchEmpresas( pattern );
- case SEARCH_ESTABELECIMENTOS:
- return searchEstabelecimentos( pattern );
- case SEARCH_TRABALHADORES:
- return searchTrabalhadores( pattern );
- case SEARCH_EXAMES:
- return searchExames( pattern );
- }
- return null;
- }
-
- public Virtual2DArray searchEmpresas( String pattern ) throws Exception {
- Select select = new Select( new String[]{ T_EMPRESAS },
- new String[]{ ID, DESIGNACAO_SOCIAL, "designacao_social_plain" },
- new Field( "designacao_social_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- new String[]{ "designacao_social_plain" }, null );
-// Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e ORDER BY lower( e.designacao_social );" );
- return executer.executeQuery( select );
- }
-
- public Virtual2DArray searchEstabelecimentos( String pattern ) throws Exception {
-// Select select = new Select( "SELECT e.id, e.nome FROM estabelecimentos e WHERE empresa_id = " + SEARCH_EMPRESAS_ID
-// + " ORDER BY lower( e.nome )");
- Select select = new Select( new String[]{ T_ESTABELECIMENTOS },
- new String[]{ ID, NOME, "nome_plain" },
- new Field( "nome_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and(
- new Field( EMPRESA_ID ).isEqual( new Integer( SEARCH_EMPRESAS_ID ) ) ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- new String[]{ "nome_plain" }, null );
- return executer.executeQuery( select );
- }
-
- public Virtual2DArray searchTrabalhadores( String pattern ) throws Exception {
-// Select select =
-// new Select( "SELECT t.id, t.nome FROM trabalhadores t, estabelecimentos es "
-// + " WHERE t.estabelecimento_id = es.id "
-// + " AND es.empresa_id = " + SEARCH_EMPRESAS_ID + " ORDER BY lower(t.nome);" );
- Select select = new Select( new String[]{ T_TRABALHADORES, T_ESTABELECIMENTOS },
- new String[]{ T_TRABALHADORES + "." + ID, T_TRABALHADORES + "." + NOME },
- new Field( T_TRABALHADORES + ".nome_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and(
- new Field( ESTABELECIMENTO_ID ).isEqual( new Field( T_ESTABELECIMENTOS + "." + ID ) ) ).and(
- new Field( ESTABELECIMENTO_ID ).isEqual( new Integer( SEARCH_ESTABELECIMENTOS_ID ) ) ).and(
- new Field( EMPRESA_ID ).isEqual( new Integer( SEARCH_EMPRESAS_ID ) ) ).and(
- new Field( T_TRABALHADORES + "." + INACTIVO ).isDifferent( "y" ) ),
- new String[]{ T_TRABALHADORES + ".nome_plain" }, null );
- return executer.executeQuery( select );
- }
-
- public Virtual2DArray searchExames( String pattern ) throws Exception {
- Select select = new Select( "SELECT e.id, e.data FROM exames e "
- + " WHERE e.trabalhador_id = " + SEARCH_TRABALHADORES_ID
- + " ORDER BY e.data DESC;" );
- return executer.executeQuery( select );
- }
-
- public void showDetails(SearchDialog dialog, Object o) throws Exception {
- }
-
- public Object [][]getAllMedicos()
- throws Exception
- {
- Select select = new Select( new String[]{ T_MEDICOS },
- new String[]{ ID, NOME, NUMERO_CEDULA },
- null, new String[]{ NOME }, null );
- Virtual2DArray array = executer.executeQuery( select );
- return array.getObjects();
- }
-
-// public void savePDF( MetaObject exame )
-// throws Exception
-// {
-// if( exame == null )
-// {
-// return;
-// }
-// DBKey key = exame.getPrimaryKeyValue();
-// DBField fields[] = EXAMES.getPrimaryKey();
-// Integer id = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() );
-// if( id == null )
-// {
-// throw new Exception( "Error saving pdf: id is null" );
-// }
-// byte []pdf = (byte[]) exame.getProperty( PDF );
-// BlobUpdate bUpdate = new BlobUpdate( T_EXAMES, PDF, pdf, new Field( ID ).isEqual( id ) );
-// executer.executeQuery( bUpdate );
-// }
-
- public Integer getLastExameIDForTrabalhador( Integer trabalhadorID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_EXAMES },
- new String[]{ ID, DATA },
- new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ),
- new String[]{ DATA + " DESC", ID + " DESC" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 )
- {
- return null;
- }
- return new Integer( ( (Number) array.get( 0, 0 ) ).intValue() );
- }
-
- public IDObject []getAllFichasForTrabalhador( Integer trabalhadorID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ T_EXAMES }, new String[]{ "MAX("+ID+")", DATA },
- new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ).and(
- new Field( INACTIVO ).isEqual( "n" ) ),
- new String[]{ DATA + " DESC" }, new String[]{ DATA } );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject exames[] = new IDObject[ array.columnLength() ];
- DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
- for( int n = 0; n < exames.length; n++ )
- {
- Date date = (Date)array.get( n, 1 );
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- exames[ n ] = new MappableObject( id, date != null? df.format( date ): "" );
- }
- return exames;
- }
-
- public IDObject []getAllEstabelecimentosForEmpresa( Integer empresaID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_ESTABELECIMENTOS },
- new String[]{ ID, NOME, "nome_plain" },
- new Field( EMPRESA_ID ).isEqual( empresaID ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- new String[]{ "nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject objects[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < objects.length; n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String desc = (String)array.get( n, 1 );
- objects[ n ] = new MappableObject( id, desc );
- }
- return objects;
- }
-
- public IDObject []getAllTrabalhadoresForEmpresa( Integer empresaID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_TRABALHADORES, T_ESTABELECIMENTOS },
- new String[]{ T_TRABALHADORES + "." + ID,
- T_TRABALHADORES + "." + NOME,
- T_TRABALHADORES + ".nome_plain" },
- new Field( T_ESTABELECIMENTOS + "." + EMPRESA_ID ).isEqual( empresaID ).and(
- new Field( T_TRABALHADORES + "." + ESTABELECIMENTO_ID ).isEqual(
- new Field( T_ESTABELECIMENTOS + "." + ID ) ) ),
- new String[]{ T_TRABALHADORES + ".nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject objects[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < objects.length; n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String desc = (String)array.get( n, 1 );
- objects[ n ] = new MappableObject( id, desc );
- }
- return objects;
- }
-
- public IDObject []getAllTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_TRABALHADORES },
- new String[]{ ID, NOME, "nome_plain" },
- new Field( ESTABELECIMENTO_ID ).isEqual( estabelecimentoID ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- new String[]{ "nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject objects[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < objects.length; n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String desc = (String)array.get( n, 1 );
- objects[ n ] = new MappableObject( id, desc );
- }
- return objects;
- }
-
- public Integer getEstabelecimentoIDForTrabalhador( Integer trabalhadorID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_TRABALHADORES },
- new String[]{ ESTABELECIMENTO_ID },
- new Field( ID ).isEqual( trabalhadorID ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- null, null );
- Virtual2DArray array = executer.executeQuery( select );
- Integer estabelecimentoID = null;
- if( array != null && array.columnLength() > 0 )
- {
- estabelecimentoID = ( Integer )array.get( 0, 0 );
- }
- return estabelecimentoID;
- }
-
- public Integer getEmpresaIDForEstabelecimento( Integer estabelecimentoID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_ESTABELECIMENTOS },
- new String[]{ EMPRESA_ID },
- new Field( ID ).isEqual( estabelecimentoID ).and(
- new Field( INACTIVO ).isDifferent( "y" ) ),
- null, null );
- Virtual2DArray array = executer.executeQuery( select );
- Integer empresaID = null;
- if( array != null && array.columnLength() > 0 )
- {
- empresaID = ( Integer )array.get( 0, 0 );
- }
- return empresaID;
- }
-
- public Integer []getAvisosIDByTipoAndDate( Integer tipo, Date date )
- throws Exception
- {
- Select select = new Select( new String[]{ "avisos" }, new String[]{ "id", "data_evento" },
- new Field( "tipo" ).isEqual( tipo ).and(
- new Field( "data_aviso" ).isLessOrEqual( date )),
- new String[]{ "data_evento" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- Integer ids[] = new Integer[ array.columnLength() ];
- for( int n = 0; n < ids.length; n++ )
- {
- ids[ n ] = new Integer( ((Number)array.get( n, 0 )).intValue() );
- }
- return ids;
- }
-
- public Object [][]getAvisosTrabalhadorByDate( Date date )
- throws Exception
- {
- Select select = new Select( new String[]{ "avisos", "empresas", "estabelecimentos", "trabalhadores" },
- new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao",
- "empresas.designacao_social", "estabelecimentos.nome",
- "trabalhadores.nome", "data_aviso" },
- new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_TRABALHADOR ) ).and(
- new Field( "data_aviso" ).isLessOrEqual( date ) ).and(
- new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and(
- new Field( "avisos.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "avisos.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ),
- new String[]{ "data_evento" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- return array.getObjects();
- }
-
- public Object [][]getAvisosEstabelecimentoByDate( Date date )
- throws Exception
- {
- Select select = new Select( new String[]{ "avisos", "empresas", "estabelecimentos" },
- new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao",
- "empresas.designacao_social", "estabelecimentos.nome", "data_aviso" },
- new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_ESTABELECIMENTO ) ).and(
- new Field( "data_aviso" ).isLessOrEqual( date ) ).and(
- new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and(
- new Field( "avisos.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ),
- new String[]{ "data_evento" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- return array.getObjects();
- }
-
- public Object [][]getAvisosEmpresaByDate( Date date )
- throws Exception
- {
- Select select = new Select( new String[]{ "avisos", "empresas" },
- new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao",
- "empresas.designacao_social", "data_aviso" },
- new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_EMPRESA ) ).and(
- new Field( "data_aviso" ).isLessOrEqual( date ) ).and(
- new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ),
- new String[]{ "data_evento" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- return array.getObjects();
- }
-
- public Integer getMarcacaoIDByTrabalhador( Integer trabalhadorID )
- throws Exception
- {
- Select realizadaSelect =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "MAX(data)" },
- new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
- new Field( "estado" ).isEqual( new Integer( 2 ) ) ).and(
- new Field( "tipo" ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_CONSULTA ) ) ) );
- Virtual2DArray realizadaArray = executer.executeQuery( realizadaSelect );
- Date realizada = (Date) realizadaArray.get( 0, 0 );
- Select select;
- if( realizada == null )
- {
- select = new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "MIN(id)" },
- new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
- new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and(
- new Field( "tipo" ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_CONSULTA ) ) ) );
- }
- else
- {
- select = new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "MIN(id)" },
- new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
- new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and(
- new Field( "data" ).isGreater( realizada ) ).and(
- new Field( "tipo" ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_CONSULTA ) ) ) );
- }
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return null;
- }
- return new Integer( ( ( Number ) array.get( 0, 0 ) ).intValue() );
- }
-
- public IDObject[] getAllEmpresasDeleted()
- throws Exception
- {
- Select select = new Select( new String[]{ T_EMPRESAS },
- new String[]{ ID, DESIGNACAO_SOCIAL, "designacao_social_plain" },
- new Field( INACTIVO ).isEqual( "y" ),
- new String[]{ "designacao_social_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject empresas[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < array.columnLength(); n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String designacao = ( String ) array.get( n, 1 );
- empresas[ n ] = new MappableObject( id, designacao );
- }
- return empresas;
- }
-
- public IDObject []getAllEstabelecimentosDeletedForEmpresa( Integer empresaID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_ESTABELECIMENTOS },
- new String[]{ ID, NOME, "nome_plain" },
- new Field( EMPRESA_ID ).isEqual( empresaID ).and(
- new Field( INACTIVO ).isEqual( "y" ) ),
- new String[]{ "nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject objects[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < objects.length; n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String desc = (String)array.get( n, 1 );
- objects[ n ] = new MappableObject( id, desc );
- }
- return objects;
- }
-
- public IDObject []getAllTrabalhadoresDeletedForEstabelecimento( Integer estabelecimentoID )
- throws Exception
- {
- Select select = new Select( new String[]{ T_TRABALHADORES },
- new String[]{ ID, NOME, "nome_plain" },
- new Field( ESTABELECIMENTO_ID ).isEqual( estabelecimentoID ).and(
- new Field( INACTIVO ).isEqual( "y" ) ),
- new String[]{ "nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- IDObject objects[] = new IDObject[ array.columnLength() ];
- for( int n = 0; n < objects.length; n++ )
- {
- Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
- String desc = (String)array.get( n, 1 );
- objects[ n ] = new MappableObject( id, desc );
- }
- return objects;
- }
-
- public Object[] getDadosUltimaMarcacao( Integer trabalhadorID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "MAX( data )" },
- new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "realizada" ).isEqual( "y" ).or(
- new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return new Object[]{ null, null };
- }
- Date data = ( Date ) array.get( 0, 0 );
- select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "motivo", "id" },
- new Field( "data" ).isEqual( data ).and(
- new Field( "trabalhador_id" ).isEqual( trabalhadorID ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "realizada" ).isEqual( "y" ).or(
- new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ),
- new String[]{ "id" }, null );
- array = executer.executeQuery( select );
- Integer tipo = ( Integer ) array.get( 0, 0 );
- if( tipo.intValue() == 5 )
- {
- tipo = new Integer( 2 );
- }
- return new Object[]{ data, tipo };
- }
-
- public void setMedicoForEstabelecimento( Integer estabelecimentoID, Integer medicoID )
- throws Exception
- {
- Integer medicoAntigo = medicosEstabelecimentosHash.get( estabelecimentoID );
- if( !medicoID.equals( medicoAntigo ) )
- {
- Update update =
- new Update( "estabelecimentos",
- new Assignment[]{
- new Assignment( new Field( "medico_id" ), medicoID ) },
- new Field( "id" ).isEqual( estabelecimentoID ) );
- executer.executeQuery( update );
- medicosEstabelecimentosHash.put( estabelecimentoID, medicoID );
- }
- }
-
- public Integer getMedicoForEstabelecimento( Integer estabelecimentoID )
- throws Exception
- {
- if( !medicosEstabelecimentosHash.containsKey( estabelecimentoID ) )
- {
- Select select =
- new Select( new String[]{ "estabelecimentos" },
- new String[]{ "medico_id" },
- new Field( "id" ).isEqual( estabelecimentoID ) );
- Virtual2DArray array = executer.executeQuery( select );
- Integer medicoID = ( Integer ) array.get( 0, 0 );
- if( medicoID == null )
- {
- medicoID = new Integer( -1 );
- }
- medicosEstabelecimentosHash.put( estabelecimentoID, medicoID );
- }
- return ( Integer ) medicosEstabelecimentosHash.get( estabelecimentoID );
- }
-
- public Long countTrabalhadoresActivosForEmpresa( Integer empresaID )
- throws Exception
- {
- Long result = 0L;
- Select2 query = new Select2( new String[]{ "trabalhadores", "estabelecimentos", "empresas" },
- new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
- new Expression[]{
- new Field("estabelecimentos.id").isEqual(new Field("trabalhadores.estabelecimento_id")),
- new Field("empresas.id").isEqual( new Field("estabelecimentos.empresa_id") ) },
- new String[]{"count(trabalhadores.id)" },
- new Field("empresas.id").isEqual( empresaID ).
- and( new Field("trabalhadores.inactivo").isEqual( "n" ) ).
- and( new Field("trabalhadores.data_demissao").isEqual( null ) ).
- and( new Field("estabelecimentos.inactivo").isEqual( "n" ) ),
- null, null, null, null );
- Virtual2DArray returned = executer.executeQuery( query );
- if( returned.columnLength() > 0 )
- {
- result = (Long) returned.get( 0, 0 );
- }
- return result;
- }
-}
diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java
index a9c5d3f1..53035b58 100644
--- a/trunk/SIPRPSoft/src/siprp/Main.java
+++ b/trunk/SIPRPSoft/src/siprp/Main.java
@@ -26,9 +26,9 @@ import shst.SHSTShutdownHook;
import shst.SHSTTracker;
import shst.companydataloaders.SIPRPPropertiesLoader;
import shst.initializer.SHSTORMInitializer;
+import shst.initializer.SHSTUIInitializer;
import shst.lembretes.LembretesDaemon;
import siprp.initializer.SIPRPLoggerInit;
-import siprp.initializer.SIPRPUIInitializer;
import siprp.update.UpdateList;
import com.evolute.module.updater.UpdateListener;
@@ -81,7 +81,7 @@ public class Main implements com.evolute.utils.ui.window.Connector
new SHSTShutdownHook().init();
- new SIPRPUIInitializer().doInit();
+ new SHSTUIInitializer().doInit();
SIPRPPropertiesLoader.getInstance().load();
@@ -141,8 +141,8 @@ public class Main implements com.evolute.utils.ui.window.Connector
JPanel left = loginWindow.getLeftPanel();
left.setBackground( Color.white );
- loginWindow.setSize( 700, 510 );
- loginWindow.setExtendedState(loginWindow.getExtendedState() | LoginWindow.MAXIMIZED_BOTH);
+ loginWindow.setSize( 600, 500 );
+ loginWindow.setExtendedState( loginWindow.getExtendedState() | LoginWindow.MAXIMIZED_BOTH );
loginWindow.setVisible( true );
SwingUtilities.invokeLater( new Runnable()
{
@@ -171,8 +171,7 @@ public class Main implements com.evolute.utils.ui.window.Connector
}
catch( Exception ex )
{
- DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer"
- + " a liga\u00E7\u00E3o \u00E0 base de dados.\n(" + url + ")", false );
+ DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer a liga\u00E7\u00E3o \u00E0 base de dados.\n(" + url + ")", false );
}
}
diff --git a/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl b/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl
deleted file mode 100644
index d98488f3..00000000
--- a/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl
+++ /dev/null
@@ -1,797 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Página
-
-
-
- de
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- imagem1
-
-
-
- ANÁLISE DE ACIDENTE DE TRABALHO
-
-
-
-
-
-
-
-
- N.º
-
-
-
-
-
- DATA:
-
- /
-
- /
-
-
-
-
-
-
-
-
-
-
- imagem2
-
-
-
-
-
-
-
-
-
-
-
-
- IDENTIFICAÇÃO DA
- ENTIDADE EMPREGADORA
-
-
-
-
-
- Identificação
- completa:
-
-
-
-
-
-
-
- Actividade desenvolvida:
-
-
-
-
-
-
-
- Loja:
-
-
-
-
-
-
-
-
-
-
-
-
- EMPRESA SEGURADORA
-
-
-
-
-
- Identificação
- completa:
-
-
-
-
-
-
-
- Nº de Apólice:
-
-
-
-
-
-
-
-
-
-
-
-
-
- EMPRESA PRESTADORA DE
- SERVIÇOS DE
- SEGURANÇA, HIGIENE E
- SAÚDE DO TRABALHO
-
-
-
-
-
- Identificação
- completa:
-
-
-
-
-
-
-
- Técnico(a) Superior
- de HST:
-
-
-
-
-
- C.A.P. nº::
-
-
-
-
-
-
-
- Médico(a) do
- Trabalho:
-
-
-
-
-
- Cédula Prof. nº:
-
-
-
-
-
-
-
-
-
-
-
-
-
- ACIDENTADO (A)
-
-
-
-
-
- Nome:
-
-
-
-
-
-
-
- Estabelecimento de
- origem:
-
-
-
-
-
-
-
- Data Nascimento:
-
- /
-
- /
-
-
-
-
-
-
-
- Bilhete de Identidade
- N°:
-
-
-
-
-
-
-
- Morada
-
-
-
-
-
-
-
- Contacto
- telefónico:
-
-
-
-
-
-
-
- Data admissão:
-
- /
-
- /
-
-
-
-
-
-
-
- Função:
-
-
-
-
-
-
-
- Turno de Trabalho:
-
-
-
-
-
-
- Identificação do superior
- hierárquico/Responsável do
- posto de trabalho
-
-
-
-
-
- Nome:
-
-
-
-
-
- E-mail:
-
-
-
-
-
-
-
-
-
-
-
-
-
- DADOS DO ACIDENTE DE
- TRABALHO
-
-
-
-
-
- Averiguador:
-
-
-
-
-
-
-
- Data da ocorrência:
-
- /
-
- /
-
-
-
-
-
- Hora do acidente:
-
- h
-
- m
-
-
-
-
-
-
- Nº horas trabalhadas no
- turno:
-
-
-
-
-
-
-
- Secção:
-
-
-
-
-
- Local específico:
-
-
-
-
-
-
-
- Tarefa/Actividade que se
- encontrava a realizar:
-
-
-
-
-
-
-
- Substâncias,
- equipamentos,
- ferramentas e objectos
- utilizados:
-
-
-
-
-
-
-
- Condições que
- contribuíram para o
- acidente e respectiva
- explicação da
- sua existência:
-
-
-
-
-
-
-
- Testemunhas:
-
-
-
-
-
-
-
- Causas do acidente:
-
-
-
-
-
-
-
- Descrição do
- acidente:
-
-
-
-
-
-
-
- Fotografia(s) e/ou
- croqui(s) do local do
- acidente:
-
-
-
-
-
-
-
-
-
- Conclusões:
-
-
-
-
-
-
-
- Acções Imediatas
- tomadas:
-
-
-
-
-
-
-
-
-
- O colaborador
- teve formação em SHST
-
-
- O colaborador não
- teve formação em SHST
-
-
-
-
-
-
- Motivo:
-
-
-
-
-
-
-
-
-
-
-
- Verificaram-se outras
- ocorrências/incidências
- no mesmo posto de
- trabalho com o
- colaborador acidentado.
-
-
- Não se verificaram outras
- ocorrências/incidências
- no mesmo posto de
- trabalho com o
- colaborador acidentado.
-
-
-
-
-
-
- Quantidade:
-
- Relatórios de acidente nº:
-
-
- ;
-
-
-
-
-
-
-
-
-
-
-
- Verificaram-se
- ocorrências/incidentes
- semelhantes com outros
- colaboradores.
-
-
- Não se verificaram
- ocorrências/incidentes
- semelhantes com outros
- colaboradores.
-
-
-
-
-
-
- Quantidade:
-
- Relatórios de acidente nº:
-
-
- ;
-
-
-
-
-
-
-
-
-
- LESÃO
-
-
-
-
-
-
- Áreas corporais
- específicas
- lesionadas:
-
-
-
-
-
-
-
-
-
- Tipo de Lesão:
-
-
-
-
-
-
-
-
- INCAPACIDADE
-
-
-
-
-
-
- Tipo de Incapacidade:
-
-
-
-
-
- Coeficiente de
- Incapacidade
-
- %
-
-
-
-
-
-
- Avaliação de
- Incapacidade realizada
- em
-
- /
-
- /
-
-
-
-
-
- Revisão de
- Incapacidade
-
- /
-
- /
-
-
-
-
-
-
-
- Período da Incapacidade
- Temporária: de
-
- /
-
- /
-
- a
-
- /
-
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
- RECOMENDAÇÕES PROPOSTAS
- pela SIPRP
-
-
-
-
-
-
-
-
-
- .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MEDIDAS A ADOPTAR PELA
- ENTIDADE EMPREGADORA
-
-
-
-
-
-
-
-
-
-
-
- .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TOMADA DE CONHECIMENTO /
- TERMO DE
- RESPONSABILIDADE
-
-
-
-
-
-
-
-
- Averiguado por
-
- (Departamento de Segurança)
- a
-
- /
-
- /
-
- .
-
-
- Verificado por
-
- (Técnico
- de HST) a
-
- /
-
- /
-
- .
-
-
- Verificado por
-
- (Responsável de Segurança) a
-
- /
-
- /
-
- .
-
-
- Verificado por
-
- (Responsável de RH) a
-
- /
-
- /
-
- .
-
-
- Com conhecimento de
-
- (Superior hierárquico) a
-
- /
-
- /
-
- .
-
- - processamento informático
- - acesso autenticado -
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java b/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java
deleted file mode 100644
index 2b5065dd..00000000
--- a/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package siprp.cursos;
-
-import shst.cursos.CursosInit;
-import siprp.cursos.provider.CursosTemplatesProvider;
-
-import com.evolute.genericpeople.TemplateProviderFactory;
-
-public class SIPRPCursosInit
-{
-
- public static void initFactory() throws Exception
- {
- //default init
- CursosInit.initFactory();
-
- //replace templates provider
- TemplateProviderFactory.setProvider( new CursosTemplatesProvider() );
- }
-
-}
diff --git a/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java b/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java
deleted file mode 100644
index d98c554b..00000000
--- a/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package siprp.cursos.provider;
-
-import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import javax.swing.JOptionPane;
-
-import shst.cursos.provider.PessoasProvider;
-
-import com.evolute.genericpeople.AutorizacaoProviderInterface;
-import com.evolute.genericpeople.DefaultTemplateProvider;
-import com.evolute.genericpeople.PessoaDocumentoConstants;
-import com.evolute.genericpeople.PessoaDocumentoInterface;
-import com.evolute.genericpeople.PessoaInterface;
-import com.evolute.genericpeople.TemplateConstants;
-import com.evolute.module.cursos.CursosDataProvider;
-import com.evolute.module.cursos.CursosLogic;
-import com.evolute.module.cursos.data.CurCursosData;
-import com.evolute.module.cursos.data.CurFormandosData;
-import com.evolute.swing.frame.EvoFrame;
-import com.evolute.utils.Singleton;
-import com.evolute.utils.error.ErrorLogger;
-import com.evolute.utils.tables.ColumnizedObjectArray;
-import com.evolute.utils.xml.SimpleXMLElement;
-
-public class CursosTemplatesProvider extends DefaultTemplateProvider
-{
- private CursosDataProvider cursosProvider = CursosDataProvider.getProvider();
-
- public CursosTemplatesProvider()
- {
- setTemplate( TemplateConstants.SUMARIOS, "com/evolute/module/cursos/templates/sumarios.xsl" );
- setTemplate( TemplateConstants.LISTA_PRESENCAS, "com/evolute/module/cursos/templates/lista_presencas.xsl" );
- setTemplate( TemplateConstants.TOPICOS_FILE, "com/evolute/module/cursos/templates/topicos.xsl" );
-
- setTemplate( TemplateConstants.CERTIFICADO_FORMANDO, "siprp/cursos/templates/certificado_formando.xsl" );
- setTemplate( TemplateConstants.CERTIFICADO_FORMADOR, "siprp/cursos/templates/certificado_formador.xsl" );
-
- setTemplate( TemplateConstants.INSCRICAO_ACEITE, "com/evolute/module/cursos/templates/inscricao_aceite.xsl" );
- setTemplate( TemplateConstants.INSCRICAO_ACEITE_POPH, "com/evolute/module/cursos/templates/inscricao_aceite_POPH.xsl" );
- setTemplate( TemplateConstants.INSCRICAO_REJEITADA, "com/evolute/module/cursos/templates/inscricao_rejeitada.xsl" );
- setTemplate( TemplateConstants.CONFIRMAR_INSCRICAO, "com/evolute/module/cursos/templates/confirmar_inscricao.xsl" );
- }
-
- @Override
- public SimpleXMLElement getXMLForImpressaoFormador( boolean visualizar, CurCursosData curso, EvoFrame parent, List< ColumnizedObjectArray > formadores )
- throws Exception
- {
- return super.getXMLForImpressaoFormador( visualizar, curso, parent, formadores );
- }
-
- @Override
- public SimpleXMLElement getXMLForImpressaoFormando( boolean visualizar, CurCursosData curso, EvoFrame parent, List< ColumnizedObjectArray > formandos )
- throws Exception
- {
- SimpleXMLElement xml = null;
- if( formandos != null && !formandos.isEmpty() )
- {
- CurFormandosData formando = cursosProvider.getFormandoByID( formandos.get( 0 ).getID() );
- PessoaInterface pessoa = cursosProvider.getPessoaFromFormando( formando );
-
- Integer numero = super.getNumeroCertificado( formando.getId(), curso.getId() );
- if( numero == null )
- {
- return null;
- }
- String numCertificado = numero.toString();
- Calendar cal = Calendar.getInstance();
- String year = "" + cal.get( Calendar.YEAR );
- year = year.substring( 2, year.length() );
- numCertificado += "/" + year;
-
- String nomePessoa = super.getNomePessoa( pessoa );
- if( nomePessoa == null )
- {
- JOptionPane.showMessageDialog( parent, "O nome do formando tem de estar preenchido!", "Erro", JOptionPane.ERROR_MESSAGE, null );
- return null;
- }
-
- String sexo = pessoa.getSexo();
- if( sexo == null )
- {
- JOptionPane.showMessageDialog( parent, "O formador tem de ter o campo sexo preenchido", "Erro", JOptionPane.ERROR_MESSAGE, null);
- return null;
- }
-
- String profissao = pessoa.getProfissao();
- if( profissao == null )
- {
- JOptionPane.showMessageDialog( parent, "A profiss" + atilde + "o do formando tem de estar preenchida!", "Erro", JOptionPane.ERROR_MESSAGE, null );
- return null;
- }
-
- String naturalidade = pessoa.getNaturalidade();
- if( naturalidade == null )
- {
- JOptionPane.showMessageDialog( parent, "A naturalidade do formando tem de estar preenchida!", "Erro", JOptionPane.ERROR_MESSAGE, null );
- return null;
- }
-
- String dataNascimento = super.getDataNascimento( pessoa );
- if( dataNascimento == null )
- {
- JOptionPane.showMessageDialog( parent, "A data de nascimento do formando tem de estar preenchida", "Erro", JOptionPane.ERROR_MESSAGE, null);
- return null;
- }
-
- String nacionalidade = super.getNacionalidade( pessoa );
- if( nacionalidade == null )
- {
- JOptionPane.showMessageDialog( parent, "A nacionalidade do formando tem de estar preenchida", "Erro", JOptionPane.ERROR_MESSAGE, null);
- return null;
- }
-
- PessoaDocumentoInterface doc = PessoasProvider.getProvider().getDocumentoByPessoaID( pessoa.getId(), PessoaDocumentoConstants.TIPO_DOCUMENTO_BI );
- String bi_numero = doc == null || "".equals( doc.getNumero().trim() ) ? "" : "portadora do Bilhete de Identidade nº " + doc.getNumero() + ", ";
- String bi_emissao = doc == null || "".equals( doc.getLocal_emissao().trim() ) ? "" : " emitido em " + doc.getLocal_emissao() + ", ";
- String bi_data_emissao = doc == null ? "" : "em " + DefaultTemplateProvider.D_F.format( doc.getData_emissao() ) + ", ";
-// String bi_numero = pessoa.getBINumero() == null || "".equals( pessoa.getBINumero().trim() ) ? "" : "portadora do Bilhete de Identidade nº " + pessoa.getBINumero() + ", ";
-// String bi_emissao = pessoa.getBIArquivo() == null || "".equals( pessoa.getBIArquivo().trim() ) ? "" : " emitido em " + pessoa.getBIArquivo() + ", ";
-// String bi_data_emissao = pessoa.getBIData() == null ? "" : "em " + DefaultTemplateProvider.D_F.format( pessoa.getBIData() ) + ", ";
-
-
- xml = new SimpleXMLElement( CERTIFICADO_FORMANDO_XML_NAME );
- xml.addElement( new SimpleXMLElement( "numero_certificado", numCertificado ) );
- xml.addElement( new SimpleXMLElement( "signature_filename1", visualizar ? "": AutorizacaoProviderInterface.ASSINATURA1_FILENAME ) );
-
- xml.addElement( new SimpleXMLElement( "nome_pessoa", nomePessoa ) );
- xml.addElement( new SimpleXMLElement( "profissao", profissao ) );
- xml.addElement( new SimpleXMLElement( "naturalidade", naturalidade ) );
- xml.addElement( new SimpleXMLElement( "data_nascimento", dataNascimento ) );
- xml.addElement( new SimpleXMLElement( "nacionalidade", nacionalidade ) );
- xml.addElement( new SimpleXMLElement( "sexo", sexo ) );
- xml.addElement( new SimpleXMLElement( "bi_numero", bi_numero ) );
- xml.addElement( new SimpleXMLElement( "bi_emissao", bi_emissao ) );
- xml.addElement( new SimpleXMLElement( "bi_data_emissao", bi_data_emissao ) );
-
- xml.addElement( new SimpleXMLElement( "nome_formadora", "TODO - nome formadora" ) );
- xml.addElement( new SimpleXMLElement( "nome_formadora_e_responsavel", "TODO - nome formadora e responsavel" ) );
-
- //TODO : numero de Livro de Registo de Formação
- xml.addElement( new SimpleXMLElement( "nr_livro_registo", " " ) );
- xml.addElement( new SimpleXMLElement( "numero_certificado", numCertificado ) );
- try
- {
- if( CursosLogic.getInstance().fillDadosCurso( parent, xml, curso, null ) )
- {
- Date today = (Date) Singleton.getInstance( Singleton.TODAY );
- SimpleXMLElement dataCorrenteElement = new SimpleXMLElement( "data_corrente", new SimpleDateFormat( "dd' de 'MMMM' de 'yyyy", new Locale( "pt", "PT" ) ).format( today ) );
- xml.addElement( dataCorrenteElement );
- System.out.println( xml );
- }
- else
- {
- xml = null;
- }
- }
- catch( Exception ex )
- {
- ErrorLogger.logException( ex );
- }
- }
- else
- {
- xml = super.generateXMLTesteFormando( parent, curso );
- }
- return xml;
- }
-
-}
diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java
deleted file mode 100644
index 6377fa32..00000000
--- a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * EstatisticaDataProvider.java
- *
- * Created on 16 de Dezembro de 2004, 12:50
- */
-
-package siprp.estatistica;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-import shst.data.Marcacao;
-import shst.data.outer.MarcacoesTrabalhadorData;
-
-import com.evolute.utils.Singleton;
-import com.evolute.utils.arrays.Virtual2DArray;
-import com.evolute.utils.db.DBManager;
-import com.evolute.utils.db.Executer;
-import com.evolute.utils.metadb.MetaProvider;
-import com.evolute.utils.sql.Field;
-import com.evolute.utils.sql.Select;
-/**
- *
- * @author fpalma
- */
-public class EstatisticaDataProvider extends MetaProvider
-{
- private static final Object LOCK = new Object();
- private static EstatisticaDataProvider instance = null;
- private final Executer executer;
-
- public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT );
-
- /** Creates a new instance of EstatisticaDataProvider */
- public EstatisticaDataProvider()
- throws Exception
- {
- DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
- executer = dbm.getSharedExecuter( this );
- }
-
- public static MetaProvider getProvider()
- throws Exception
- {
- synchronized( LOCK )
- {
- if( instance == null )
- {
- instance = new EstatisticaDataProvider();
- }
- }
- return instance;
- }
-
- public String[][] getMarcacoesPeriodo( Date dataInicio, Date dataFim )
- throws Exception
- {
- String [][]result = null;
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ MarcacoesTrabalhadorData.DATA,
- "trabalhador_id",
- MarcacoesTrabalhadorData.REALIZADA,
- MarcacoesTrabalhadorData.TIPO },
- new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ),
- new String[]{ "data" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- result = new String[ array.columnLength() ][ 5 ];
- for( int n = 0; n < result.length; n++ )
- {
- Date data = ( Date ) array.get( n, 0 );
- int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
- boolean realizada = "y".equals( array.get( n, 2 ) );
- int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
- String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
- result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
- result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
- result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
- result[ n ][ 3 ] = DF.format( data );
- result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
-
- }
- return result;
- }
-
- public String[] getNomeEstabelecimentoEmpresaForTrabalhador( int trabalhadorID )
- throws Exception
- {
- String data[] = new String[ 3 ];
- Select select =
- new Select( new String[]{ "trabalhadores", "estabelecimentos", "empresas"},
- new String[]{ "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social" },
- new Field( "trabalhadores.id" ).isEqual( new Integer( trabalhadorID ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 1 )
- {
- data[ 0 ] = ( String ) array.get( 0, 0 );
- data[ 1 ] = ( String ) array.get( 0, 1 );
- data[ 2 ] = ( String ) array.get( 0, 2 );
- }
- return data;
- }
-
- public int countExamesPeriodo( Date dataInicio, Date dataFim )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "count(*)" },
- new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public int countConsultasPeriodo( Date dataInicio, Date dataFim )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "count(*)" },
- new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public int countExamesPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
- new String[]{ "count(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public int countConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
- new String[]{ "count(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public String[][] getMarcacoesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
- throws Exception
- {
- String [][]result = null;
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
- new String[]{ MarcacoesTrabalhadorData.DATA,
- "trabalhador_id",
- MarcacoesTrabalhadorData.REALIZADA,
- MarcacoesTrabalhadorData.TIPO },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ),
- new String[]{ "data" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- result = new String[ array.columnLength() ][ 5 ];
- for( int n = 0; n < result.length; n++ )
- {
- Date data = ( Date ) array.get( n, 0 );
- int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
- boolean realizada = "y".equals( array.get( n, 2 ) );
- int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
- String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
- result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
- result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
- result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
- result[ n ][ 3 ] = DF.format( data );
- result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
-
- }
- return result;
- }
-
- public int countExamesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
- new String[]{ "count(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public int countConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
- new String[]{ "count(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
- {
- return 0;
- }
- return ( ( Number ) array.get( 0, 0 ) ).intValue();
- }
-
- public String[][] getTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
-// Select subSelect =
-// new Select( new String[]{ "marcacoes_trabalhador" },
-// new String[]{ "trabalhador_id" },
-// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
-// new Field( "realizada" ).isEqual( "y" ) ) );
- Select select =
- new Select( new String[]{ "empresas", "estabelecimentos",
- "trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
- + "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
- + (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
- new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
- "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
- new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ).or(
- new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ),
- new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 3 ];
- for( int r = 0; r < array.columnLength(); r++ )
- {
- for( int c = 0; c < 3; c++ )
- {
- data[ r ][ c ] = (String) array.get( r, c );
- }
- }
- return data;
- }
-
-
-
- public int countTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
- new Field( "inactivo" ).isDifferent( "y" ) );
- int totalCount = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- totalCount = n.intValue();
- }
- }
-
-// select =
-// new Select( new String[]{ "marcacoes_trabalhador" },
-// new String[]{ "COUNT(*)" },
-// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
-// new Field( "realizada" ).isEqual( "y" ) ).and(
-// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
-// int subCount = 0;
-// array = executer.executeQuery( select );
-// if( array.columnLength() > 0 && array.rowLength() > 0 )
-// {
-// Number n = (Number) array.get( 0, 0 );
-// if( n != null )
-// {
-// subCount = n.intValue();
-// }
-// }
-
- return totalCount - countTrabalhadoresComExamesOuConsultasPeriodo( dataInicio, dataFim, exames );
- }
-
- public String[][] getTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador" },
- new String[]{ "trabalhador_id" },
- new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "realizada" ).isEqual( "y" ) ) );
- Virtual2DArray array = executer.executeQuery( select );
- Integer ids[] = new Integer[ array.columnLength() ];
- for( int n = 0; n < ids.length; n++ )
- {
- ids[ n ] = ( Integer ) array.get( n, 0 );
- }
- if( ids.length == 0 )
- {
- ids = new Integer[]{ new Integer( -1 ) };
- }
- select =
- new Select( new String[]{ "estabelecimentos",
- "trabalhadores" },
- new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
- new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.id" ).notIn( ids ) ),
- new String[]{ "trabalhadores.nome" }, null );
-// Select select =
-// new Select( new String[]{ "estabelecimentos",
-// "trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
-// + "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
-// + (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
-// new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
-// new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
-// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
-// new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
-// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ).or(
-// new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
-// new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
-// new Field( "data" ).isLessOrEqual( dataFim ) ).and(
-// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
-// new String[]{ "trabalhadores.nome" }, null );
- array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 2 ];
- for( int r = 0; r < array.columnLength(); r++ )
- {
- for( int c = 0; c < 2; c++ )
- {
- data[ r ][ c ] = (String) array.get( r, c );
- }
- }
- return data;
- }
-
- public Object[][] getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "empresas" },
- new String[]{ "id", "designacao_social", "designacao_social_plain" },
- new Field( "inactivo" ).isDifferent( "y" ),
- new String[]{ "designacao_social_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- Object data[][] = new Object[ array.columnLength() ][ 3 ];
- for( int n = 0; n < data.length; n++ )
- {
- data[ n ][ 0 ] = array.get( n, 1 );
- Integer empresaID = (Integer)array.get( n, 0 );
- data[ n ][ 1 ] = new Integer( countTrabalhadoresSemExamesOuConsultasEmpresa( empresaID, dataInicio, dataFim, exames ) );
- data[ n ][ 2 ] = empresaID;
- }
- return data;
- }
-
- public int countTrabalhadoresSemExamesOuConsultasEmpresa( Integer empresaID, Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "trabalhadores", "estabelecimentos" }, new String[]{ "COUNT(*)" },
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
- int totalCount = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- totalCount = n.intValue();
- }
- }
-
-// select =
-// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
-// new String[]{ "COUNT(*)" },
-// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
-// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
-// new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
-// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
-// new Field( "realizada" ).isEqual( "y" ) ).and(
-// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
-// int subCount = 0;
-// array = executer.executeQuery( select );
-// if( array.columnLength() > 0 && array.rowLength() > 0 )
-// {
-// Number n = (Number) array.get( 0, 0 );
-// if( n != null )
-// {
-// subCount = n.intValue();
-// }
-// }
- return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames );
- }
-
- public int countTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
- int totalCount = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- totalCount = n.intValue();
- }
- }
-
-// select =
-// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
-// new String[]{ "COUNT(*)" },
-// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
-// new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
-// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
-// new Field( "realizada" ).isEqual( "y" ) ).and(
-// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
-// int subCount = 0;
-// array = executer.executeQuery( select );
-// if( array.columnLength() > 0 && array.rowLength() > 0 )
-// {
-// Number n = (Number) array.get( 0, 0 );
-// if( n != null )
-// {
-// subCount = n.intValue();
-// }
-// }
- return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( dataInicio, dataFim, estabelecimentoID, exames );
- }
-
- public String[][]getTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "empresas", "estabelecimentos",
- "trabalhadores", "marcacoes_trabalhador" },
- new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
- "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
- new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
- new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ),
- new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 3 ];
- for( int r = 0; r < array.columnLength(); r++ )
- {
- for( int c = 0; c < 3; c++ )
- {
- data[ r ][ c ] = (String) array.get( r, c );
- }
- }
- return data;
- }
-
- public int countTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
- new String[]{ "COUNT(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "realizada" ).isEqual( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ) );
- int count = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- count = n.intValue();
- }
- }
- return count;
- }
-
- public String[][]getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "estabelecimentos",
- "trabalhadores", "marcacoes_trabalhador" },
- new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
- new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
- new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ),
- new String[]{ "estabelecimentos.nome", "trabalhadores.nome" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 2 ];
- for( int r = 0; r < array.columnLength(); r++ )
- {
- for( int c = 0; c < 2; c++ )
- {
- data[ r ][ c ] = (String) array.get( r, c );
- }
- }
- return data;
- }
-
- public Object[][] getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "empresas" },
- new String[]{ "id", "designacao_social", "designacao_social_plain" },
- new Field( "inactivo" ).isDifferent( "y" ),
- new String[]{ "designacao_social_plain" }, null );
- Virtual2DArray array = executer.executeQuery( select );
- Object data[][] = new Object[ array.columnLength() ][ 3 ];
- for( int n = 0; n < data.length; n++ )
- {
- data[ n ][ 0 ] = array.get( n, 1 );
- Integer empresaID = (Integer)array.get( n, 0 );
- data[ n ][ 1 ] = new Integer( countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames ) );
- data[ n ][ 2 ] = empresaID;
- }
- return data;
- }
-
- public int countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
- new String[]{ "COUNT(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
- new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "realizada" ).isEqual( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ) );
- int count = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- count = n.intValue();
- }
- }
- return count;
- }
-
- public int countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
- new String[]{ "COUNT(*)" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
- new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
- new Field( "realizada" ).isEqual( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
- new Field( "data" ).isLessOrEqual( dataFim ) ) );
- int count = 0;
- Virtual2DArray array = executer.executeQuery( select );
- if( array.columnLength() > 0 && array.rowLength() > 0 )
- {
- Number n = (Number) array.get( 0, 0 );
- if( n != null )
- {
- count = n.intValue();
- }
- }
- return count;
- }
-
- public String [][]getDadosTrabalhadoresPeriodo( Date dataInicio, Date dataFim )
- throws Exception
- {
- Select select =
- new Select( new String[]{ "empresas", "estabelecimentos", "trabalhadores" },
- new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome", "trabalhadores.id",
- "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
- new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
- new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
- new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
-
- Virtual2DArray array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 7 ];
- for( int n = 0; n < array.columnLength(); n++ )
- {
- data[ n ][ 0 ] = ( String ) array.get( n, 0 );
- data[ n ][ 1 ] = ( String ) array.get( n, 1 );
- data[ n ][ 2 ] = ( String ) array.get( n, 2 );
- Integer id = new Integer( ( (Number) array.get( n, 3 ) ).intValue() );
- Select exameSelect =
- new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
- new String[]{ "data", "realizada" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.id" ).isEqual( id ) ).and(
- new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
- new String[]{ "data desc" }, null );
- Virtual2DArray exameArray = executer.executeQuery( exameSelect );
- if( exameArray.columnLength() > 0 )
- {
- Date dataExame = ( Date ) exameArray.get( 0, 0 );
- String estado = ( String ) exameArray.get( 0, 1 );
- data[ n ][ 3 ] = DF.format( dataExame );
- data[ n ][ 4 ] = "y".equals( estado ) ? "Realizado" : "Faltou";
- }
- else
- {
- data[ n ][ 3 ] = "--";
- data[ n ][ 4 ] = "--";
- }
-
- Select consultaSelect =
- new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
- new String[]{ "data", "realizada" },
- new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
- new Field( "trabalhadores.id" ).isEqual( id ) ).and(
- new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
- new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
- new String[]{ "data desc" }, null );
- Virtual2DArray consultaArray = executer.executeQuery( consultaSelect );
- if( consultaArray.columnLength() > 0 )
- {
- Date dataConsulta = ( Date ) consultaArray.get( 0, 0 );
- String estado = ( String ) consultaArray.get( 0, 1 );
- data[ n ][ 5 ] = DF.format( dataConsulta );
- data[ n ][ 6 ] = "y".equals( estado ) ? "Realizada" : "Faltou";
- }
- else
- {
- data[ n ][ 5 ] = "--";
- data[ n ][ 6 ] = "--";
- }
- }
- return data;
- }
-
- public String[][]getDadosHigieneSeguranca()
- throws Exception
- {
- Select select =
- new Select( new String[]{ "empresas", "estabelecimentos" },
- new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "estabelecimentos.id",
- "empresas.designacao_social_plain", "estabelecimentos.nome_plain" },
- new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
- new Field( "empresas.inactivo" ).isDifferent( "y" ) ).and(
- new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ),
- new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain" }, null );
-
- Virtual2DArray array = executer.executeQuery( select );
- String data[][] = new String[ array.columnLength() ][ 6 ];
- for( int n = 0; n < array.columnLength(); n++ )
- {
- data[ n ][ 0 ] = ( String ) array.get( n, 0 );
- data[ n ][ 1 ] = ( String ) array.get( n, 1 );
- Integer id = new Integer( ( (Number) array.get( n, 2 ) ).intValue() );
- Select ultimaSelect =
- new Select( new String[]{ "marcacoes_estabelecimento" },
- new String[]{ "data", "realizada", "data_relatorio" },
- new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
- new Field( "marcacoes_estabelecimento.data" ).isLessOrEqual( new Date() ) ),
- new String[]{ "data desc" }, null );
- Virtual2DArray ultimaArray = executer.executeQuery( ultimaSelect );
- if( ultimaArray.columnLength() > 0 )
- {
- Date dataAud = ( Date ) ultimaArray.get( 0, 0 );
- String estado = ( String ) ultimaArray.get( 0, 1 );
- Date dataRel = ( Date ) ultimaArray.get( 0, 2 );
- data[ n ][ 2 ] = DF.format( dataAud );
- data[ n ][ 3 ] = "y".equals( estado ) ? "Realizada" : "Não Realizada";
- data[ n ][ 4 ] = dataRel != null ? DF.format( dataRel ) : "--";
- }
- else
- {
- data[ n ][ 2 ] = "--";
- data[ n ][ 3 ] = "--";
- data[ n ][ 4 ] = "--";
- }
-
- Select proximaSelect =
- new Select( new String[]{ "marcacoes_estabelecimento" },
- new String[]{ "data" },
- new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
- new Field( "marcacoes_estabelecimento.data" ).isGreaterOrEqual( new Date() ) ),
- new String[]{ "data desc" }, null );
- Virtual2DArray proximaArray = executer.executeQuery( proximaSelect );
- if( proximaArray.columnLength() > 0 )
- {
- Date dataProx = ( Date ) proximaArray.get( 0, 0 );
- data[ n ][ 5 ] = DF.format( dataProx );
- }
- else
- {
- data[ n ][ 5 ] = "--";
- }
- }
- return data;
- }
-
-
-
-}
-
diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java
deleted file mode 100644
index 3d29f2f4..00000000
--- a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java
+++ /dev/null
@@ -1,1359 +0,0 @@
-/*
- * EstatisticaWindow.java
- *
- * Created on 16 de Dezembro de 2004, 13:50
- */
-
-package siprp.estatistica;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FileDialog;
-import java.awt.FlowLayout;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemListener;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Vector;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionListener;
-
-import shst.data.outer.EmpresasData;
-import shst.data.outer.EstabelecimentosData;
-import siprp.pesquisas.PesquisasProvider;
-import siprp.ui.SIPRPFrame;
-
-import com.evolute.entity.ProviderInterface;
-import com.evolute.utils.Singleton;
-import com.evolute.utils.data.IDObject;
-import com.evolute.utils.data.MappableObject;
-import com.evolute.utils.documents.YearDocument;
-import com.evolute.utils.tables.BaseTable;
-import com.evolute.utils.tables.VectorTableModel;
-import com.evolute.utils.tracker.TrackableWindow;
-import com.evolute.utils.ui.DialogException;
-import com.evolute.utils.ui.calendar.JCalendarPanel;
-import com.evolute.utils.ui.text.CopyPasteHandler;
-/**
- *
- * @author fpalma
- */
-public class EstatisticaWindow extends SIPRPFrame
- implements TrackableWindow, ListSelectionListener, ActionListener, ItemListener
-{
- public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT );
-
- public static final int NONE = 0;
- public static final int LISTAGEM_GERAL_MARCACOES_PERIODO = 1;
- public static final int LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO = 2;
- public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES = 3;
- public static final int LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO = 4;
- public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO = 5;
- public static final int LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO = 6;
- public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA = 7;
- public static final int LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO = 8;
- public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO = 9;
- public static final int LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO = 10;
- public static final int LISTAGEM_GLOBAL_TRABALHADORES_PERIODO = -1;
- public static final int LISTAGEM_GLOBAL_HIGIENE_SEGURANCA = 11;
-
- public static final String ESTATISTICAS[] =
- new String[]{ "",
- "Marca\u00e7\u00f5es efectuadas e pendentes (geral)",
- "Marca\u00e7\u00f5es efectuadas e pendentes (por Empresa e Estabelecimento)",
- "Contagem global de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo)",
- "Listagem de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo, Empresa e Estabelecimento)",
- "Contagem global de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo)",
- "Listagem de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo, Empresa e Estabelecimento)",
- "Contagem global de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo)",
- "Listagem de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)",
- "Contagem global de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo)",
- "Listagem de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)",
- //"Listagem global de trabalhadores (por per\u00edodo)",
- "Listagem global com os dados de higiene e seguran\u00e7a" };
-
-
- public static final int OPTION_INTERVALO = 0;
- public static final int OPTION_ANO = 1;
- public static final int OPTION_EMPRESA = 2;
- public static final int OPTION_ESTABELECIMENTO = 0;
-
- public static final boolean ESTATISTICAS_OPTIONS[][] =
- // intervalo, ano, empresa, estabelecimento
- new boolean[][]{ { false, false, false, false },
- { true, false, false, false },
- { true, false, true, true },
- { true, false, false, false },
- { true, false, true, true },
- { true, false, false, false },
- { true, false, true, true },
- { true, false, false, false },
- { true, false, true, true },
- { true, false, false, false },
- { true, false, true, true },
-// { true, false, false, false },
- { false, false, false, false } };
-
- private ProviderInterface JDO;
- private EstatisticaDataProvider provider;
- private PesquisasProvider pesquisasProvider;
-
- private JComboBox estatisticaCombo;
- private JCalendarPanel dataInicioPanel;
- private JCalendarPanel dataFimPanel;
- private JTextField anoText;
- private BaseTable empresasTable;
- private VectorTableModel empresasModel;
- private BaseTable estabelecimentosTable;
- private VectorTableModel estabelecimentosModel;
- private JButton pesquisarButton;
- private JButton excelButton;
- private JEditorPane resultadoText;
-
- /** Creates a new instance of EstatisticaWindow */
- public EstatisticaWindow()
- throws Exception
- {
- provider = (EstatisticaDataProvider)EstatisticaDataProvider.getProvider();
- pesquisasProvider = (PesquisasProvider)PesquisasProvider.getProvider();
- JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
- setupComponents();
- }
-
- private void setupComponents()
- {
- setSize( 1000, 700 );
- setTitle( "Listagens" );
-
- JLabel estatisticaLabel = new JLabel( "Listagem" );
- estatisticaCombo = new JComboBox();
- for( int n = 0; n < ESTATISTICAS.length; n++ )
- {
- estatisticaCombo.addItem( ESTATISTICAS[ n ] );
- }
- estatisticaCombo.setSelectedIndex( 0 );
- estatisticaCombo.addItemListener( this );
- estatisticaCombo.setPreferredSize( new Dimension( 700, 20 ) );
- JLabel intervalo1Label = new JLabel( "De" );
- JLabel intervalo2Label = new JLabel( "a" );
- dataInicioPanel = new JCalendarPanel( null );
- dataInicioPanel.setPreferredSize( new Dimension( 200, 20 ) );
- dataFimPanel = new JCalendarPanel( null );
- dataFimPanel.setPreferredSize( new Dimension( 200, 20 ) );
-
- JLabel anoLabel = new JLabel( "Ano" );
- anoText = new JTextField();
- anoText.setDocument( new YearDocument() );
- anoText.setPreferredSize( new Dimension( 50, 20 ) );
- new CopyPasteHandler( anoText );
-
- empresasModel = new VectorTableModel( new String[]{ "Designa\u00e7\u00e3o Social" } );
- empresasTable = new BaseTable( empresasModel );
- empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
- empresasTable.setNonResizableNorReordable();
- empresasTable.getSelectionModel().addListSelectionListener( this );
- JScrollPane empresasScroll = new JScrollPane();
- empresasScroll.setViewportView( empresasTable );
- empresasScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
- empresasScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
- empresasScroll.getVerticalScrollBar().setBlockIncrement(20);
-
- estabelecimentosModel = new VectorTableModel( new String[]{ "Nome" } );
- estabelecimentosTable = new BaseTable( estabelecimentosModel );
- estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
- estabelecimentosTable.setNonResizableNorReordable();
- estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
- JScrollPane estabelecimentosScroll = new JScrollPane();
- estabelecimentosScroll.setViewportView( estabelecimentosTable );
- estabelecimentosScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
- estabelecimentosScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
-
- pesquisarButton = new JButton( "Pesquisar" );
- pesquisarButton.addActionListener( this );
- excelButton = new JButton( "Exportar" );
- excelButton.addActionListener( this );
-
- resultadoText = new JEditorPane( "text/html", "" );
- resultadoText.setEditable( false );
-// resultadoText.setLineWrap( true );
-// resultadoText.setWrapStyleWord( true );
- new CopyPasteHandler( resultadoText );
- JScrollPane resultadoScroll = new JScrollPane();
- resultadoScroll.setViewportView( resultadoText );
- resultadoScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
- resultadoScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
-
- JPanel pad;
-
- GridBagLayout gridbag = new GridBagLayout();
- getContentPane().setLayout( gridbag );
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.insets = new Insets( 5, 5, 5, 5 );
-
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.weighty = 0;
- constraints.gridheight = 1;
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
-
- JPanel escolhaEstatisticaPanel = new JPanel();
- escolhaEstatisticaPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
- escolhaEstatisticaPanel.add( estatisticaLabel );
- escolhaEstatisticaPanel.add( estatisticaCombo );
- gridbag.setConstraints( escolhaEstatisticaPanel, constraints );
- getContentPane().add( escolhaEstatisticaPanel );
-
- JPanel periodoPanel = new JPanel();
- periodoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
- periodoPanel.add( intervalo1Label );
- periodoPanel.add( dataInicioPanel );
- periodoPanel.add( intervalo2Label );
- periodoPanel.add( dataFimPanel );
- gridbag.setConstraints( periodoPanel, constraints );
- getContentPane().add( periodoPanel );
-
- JPanel anoPanel = new JPanel();
- anoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
- anoPanel.add( anoLabel );
- anoPanel.add( anoText );
- gridbag.setConstraints( anoPanel, constraints );
- getContentPane().add( anoPanel );
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.weighty = 0.2;
- constraints.gridheight = 2;
- constraints.weightx = 0.3;
- constraints.gridwidth = 3;
-
- JPanel empresasPanel = new JPanel( new BorderLayout() );
- empresasPanel.add( empresasScroll );
- empresasPanel.setBorder( BorderFactory.createTitledBorder( "Empresa" ) );
-
- gridbag.setConstraints( empresasPanel, constraints );
- getContentPane().add( empresasPanel );
-
- JPanel panel = new JPanel( new BorderLayout() );
- panel.setBorder( BorderFactory.createTitledBorder( "Estabelecimento" ) );
- panel.add( estabelecimentosScroll );
-
- gridbag.setConstraints( panel, constraints );
- getContentPane().add( panel );
-
- constraints.weighty = 0;
- constraints.gridheight = 1;
- constraints.weightx = 0.4;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- pad = new JPanel();
- gridbag.setConstraints( pad, constraints );
- getContentPane().add( pad );
-
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.weighty = 0;
- constraints.gridheight = 1;
- constraints.weightx = 0;
- constraints.gridwidth = 1;
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout( new GridLayout( 1, 1 ) );
- buttonPanel.add( pesquisarButton );
- buttonPanel.add( excelButton );
- gridbag.setConstraints( buttonPanel, constraints );
- getContentPane().add( buttonPanel );
-
- constraints.weighty = 0;
- constraints.gridheight = 1;
- constraints.weightx = 0.4;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- pad = new JPanel();
- gridbag.setConstraints( pad, constraints );
- getContentPane().add( pad );
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.weighty = 0.8;
- constraints.gridheight = GridBagConstraints.REMAINDER;
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
-
- JPanel resultadoPanel = new JPanel( new BorderLayout() );
- resultadoPanel.add( resultadoScroll );
-
- gridbag.setConstraints( resultadoPanel, constraints );
- getContentPane().add( resultadoPanel );
-
- processarEscolha();
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e)
- {
- Object source = e.getSource();
- if( source.equals( pesquisarButton ) )
- {
- int index = estatisticaCombo.getSelectedIndex();
- switch( index )
- {
- case LISTAGEM_GERAL_MARCACOES_PERIODO:
- listagemGeralMarcacoesPeriodo();
- break;
-
- case LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO:
- listagemMarcacoesPeriodoEmpresaEstabelecimento();
- break;
-
- case LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES:
- listagemGeralTrabalhadoresSemExamesOuConsultas( true );
- break;
-
- case LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO:
- listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( true );
- break;
-
- case LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO:
- listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( true );
- break;
-
- case LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO:
- listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( true );
- break;
-
- case LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA:
- listagemGeralTrabalhadoresSemExamesOuConsultas( false );
- break;
-
- case LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO:
- listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( false );
- break;
-
- case LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO:
- listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( false );
- break;
-
- case LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO:
- listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( false );
- break;
-
- case LISTAGEM_GLOBAL_TRABALHADORES_PERIODO:
- listagemGeralTrabalhadoresPeriodo();
- break;
-
- case LISTAGEM_GLOBAL_HIGIENE_SEGURANCA:
- listagemGlobalHigieneSeguranca();
- break;
- }
- }
- else if( source.equals( excelButton ) )
- {
- exportar();
- }
- }
-
- private boolean close()
- {
- setVisible( false );
- dispose();
- return true;
- }
-
- public boolean closeIfPossible()
- {
- return close();
- }
-
- public void open()
- {
- empresasTable.clearSelection();
- estatisticaCombo.setSelectedIndex( 0 );
- try
- {
- IDObject empresas[] = pesquisasProvider.getAllEmpresas();
- empresasModel.setValues( new Vector( Arrays.asList( empresas ) ) );
- }
- catch( Exception ex )
- {
- DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
- }
- setVisible( true );
- }
-
- public void refresh()
- {
- setVisible( true );
- }
-
- public void valueChanged(javax.swing.event.ListSelectionEvent e)
- {
- Object source = e.getSource();
- if( source.equals( empresasTable.getSelectionModel() ) )
- {
- estabelecimentosTable.clearSelection();
- int selected = empresasTable.getSelectedRow();
- if( selected == -1 )
- {
- return;
- }
- IDObject empresa = (IDObject) empresasModel.getRowAt( selected );
- estabelecimentosModel.clearAll();
- IDObject estabelecimentos[];
- try
- {
- estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( empresa.getID() );
- }
- catch( Exception ex )
- {
- DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos", true );
- return;
- }
- Vector v = new Vector( Arrays.asList( estabelecimentos ) );
- v.add( new MappableObject( new Integer( -1 ), "TODOS" ) );
- estabelecimentosModel.setValues( v );
- }
- }
-
- public void itemStateChanged(java.awt.event.ItemEvent itemEvent)
- {
- processarEscolha();
- }
-
- protected void processarEscolha()
- {
- int index = estatisticaCombo.getSelectedIndex();
- boolean optionLine[] = ESTATISTICAS_OPTIONS[ index ];
- dataInicioPanel.setEnabled( optionLine[ OPTION_INTERVALO ] );
- dataFimPanel.setEnabled( optionLine[ OPTION_INTERVALO ] );
- anoText.setEnabled( optionLine[ OPTION_ANO ] );
- empresasTable.setEnabled( optionLine[ OPTION_EMPRESA ] );
- estabelecimentosTable.setEnabled( optionLine[ OPTION_ESTABELECIMENTO ] );
- pesquisarButton.setEnabled( index != NONE );
- }
-
- protected void listagemGeralMarcacoesPeriodo()
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- if( inicio == null || fim == null )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- StringBuffer buffer = new StringBuffer();
- int exames = provider.countExamesPeriodo( inicio, fim );
- int consultas = provider.countConsultasPeriodo( inicio, fim );
- int total = exames + consultas;
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ LISTAGEM_GERAL_MARCACOES_PERIODO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EXAMES:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + exames + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "CONSULTAS:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + consultas + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "TOTAL:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + ( exames + consultas ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "NOME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "DATA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( " " );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getMarcacoesPeriodo( inicio, fim );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 0; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemMarcacoesPeriodoEmpresaEstabelecimento()
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- int sEmpresa = empresasTable.getSelectedRow();
- int sEstabelecimento = estabelecimentosTable.getSelectedRow();
- if( inicio == null || fim == null || sEmpresa == -1 )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- StringBuffer buffer = new StringBuffer();
- Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
- EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa );
- String designacao = (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL );
- IDObject estabelecimentos[];
- if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
- {
- estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
- }
- else
- {
- estabelecimentos = new IDObject[ 1 ];
- estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
- }
- int examesEmpresa = provider.countExamesPeriodoForEmpresa( inicio, fim, idEmpresa );
- int consultasEmpresa = provider.countConsultasPeriodoForEmpresa( inicio, fim, idEmpresa );
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + designacao + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EXAMES:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + examesEmpresa + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "CONSULTAS:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + consultasEmpresa + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "TOTAL:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + ( examesEmpresa + consultasEmpresa ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
- for( int e = 0; e < estabelecimentos.length; e++ )
- {
- EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() );
- String nome = (String)estabelecimento.get( EstabelecimentosData.NOME );
- int exames = provider.countExamesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
- int consultas = provider.countConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
- int total = exames + consultas;
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "ESTABELECIMENTO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + nome + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EXAMES:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + exames + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "CONSULTAS:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + consultas + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "TOTAL:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + ( exames + consultas ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "NOME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "DATA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( " " );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getMarcacoesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 1; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- }
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemGeralTrabalhadoresSemExamesOuConsultas( boolean exames )
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- if( inicio == null || fim == null )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- int count = provider.countTrabalhadoresSemExamesOuConsultas( inicio, fim, exames );
- //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
- Object data[][] = provider.getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames );
- StringBuffer buffer = new StringBuffer();
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES : LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "TOTAL:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + count + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "N\u00ba" );
- buffer.append( " | " );
- buffer.append( " | " );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "
" );
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ 0 ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
-
- buffer.append( "" );
- buffer.append( "" + data[ l ][ 1 ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- }
- buffer.append( "
" );
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( boolean exames )
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- if( inicio == null || fim == null )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- int sEmpresa = empresasTable.getSelectedRow();
- int sEstabelecimento = estabelecimentosTable.getSelectedRow();
- if( sEmpresa == -1 )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher Empresa.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- StringBuffer buffer = new StringBuffer();
- Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
- EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa );
- String designacao = (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL );
- IDObject estabelecimentos[];
- if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
- {
- estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
- }
- else
- {
- estabelecimentos = new IDObject[ 1 ];
- estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
- }
- int countEmpresa = provider.countTrabalhadoresSemExamesOuConsultasEmpresa( idEmpresa, inicio, fim, exames );
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + designacao + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "Nº DE TRABALHADORES:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + countEmpresa + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
- for( int e = 0; e < estabelecimentos.length; e++ )
- {
- EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() );
- String nome = (String)estabelecimento.get( EstabelecimentosData.NOME );
- int countEstabelecimento = provider.countTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "ESTABELECIMENTO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + nome + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "Nº DE TRABALHADORES:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + countEstabelecimento + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "NOME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 0; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- }
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( boolean exames )
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- if( inicio == null || fim == null )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- int count = provider.countTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
- //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
- Object data[][] = provider.getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames );
- StringBuffer buffer = new StringBuffer();
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO : LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "TOTAL:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + count + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "N\u00ba" );
- buffer.append( " | " );
- buffer.append( " | " );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "
" );
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ 0 ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
-
- buffer.append( "" );
- buffer.append( "" + data[ l ][ 1 ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- }
- buffer.append( "
" );
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( boolean exames )
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- int sEmpresa = empresasTable.getSelectedRow();
- int sEstabelecimento = estabelecimentosTable.getSelectedRow();
- if( inicio == null || fim == null || sEmpresa == -1 )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- StringBuffer buffer = new StringBuffer();
- Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
- EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa );
- String designacao = (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL );
- IDObject estabelecimentos[];
- if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
- {
- estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
- }
- else
- {
- estabelecimentos = new IDObject[ 1 ];
- estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
- }
- int countEmpresa = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( inicio, fim, idEmpresa, exames );
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + designacao + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "Nº:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + countEmpresa + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "
" );
- for( int e = 0; e < estabelecimentos.length; e++ )
- {
- EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() );
- String nome = (String)estabelecimento.get( EstabelecimentosData.NOME );
- int countEstabelecimento = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "ESTABELECIMENTO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + nome + "" );
- buffer.append( " | " );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "Nº:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + countEstabelecimento + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "NOME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 0; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- }
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemGeralTrabalhadoresPeriodo()
- {
- try
- {
- Date inicio = dataInicioPanel.getDate();
- Date fim = dataFimPanel.getDate();
- if( inicio == null || fim == null )
- {
- JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- if( inicio.after( fim ) )
- {
- JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
- JOptionPane.ERROR_MESSAGE );
- resultadoText.setText( "ERRO!" );
- return;
- }
- StringBuffer buffer = new StringBuffer();
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_TRABALHADORES_PERIODO ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "PER\u00cdODO:" );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
- + DF.format( dataFimPanel.getDate() ) + "" );
- buffer.append( " | " );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "NOME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ÚLTIMO EXAME" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTADO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ÚLTIMA CONSULTA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTADO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getDadosTrabalhadoresPeriodo( inicio, fim );
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 0; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- protected void listagemGlobalHigieneSeguranca()
- {
- try
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append( "" );
- buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_HIGIENE_SEGURANCA ] + "" );
- buffer.append( "
" );
- buffer.append( "
" );
-
- buffer.append( "" );
- buffer.append( "" );
- buffer.append( "| " );
- buffer.append( "EMPRESA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTABELECIMENTO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ÚLTIMA AUDITORIA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "ESTADO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "RELATÓRIO" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "" );
- buffer.append( "PRÓXIMA AUDITORIA" );
- buffer.append( " | " );
- buffer.append( " | " );
- buffer.append( "
" );
- String data[][] = provider.getDadosHigieneSeguranca();
- for( int l = 0; l < data.length; l++ )
- {
- buffer.append( "" );
- for( int c = 0; c < data[ l ].length; c++ )
- {
- buffer.append( "| " );
- buffer.append( "" + data[ l ][ c ] + "" );
- buffer.append( " | " );
- buffer.append( " | " );
- }
- buffer.append( "
" );
- }
- buffer.append( "
" );
- resultadoText.setText( buffer.toString() );
- }
- catch( Exception ex )
- {
- resultadoText.setText( "ERRO a carregar dados!" );
- ex.printStackTrace();
- }
- }
-
- public void exportar()
- {
- FileDialog dialog = new FileDialog( this, "Ficheiro de destino", FileDialog.SAVE );
- dialog.setDirectory( System.getProperty( "user.home" ) );
- dialog.setVisible( true );
- String fileName;
- String dirName;
- fileName = dialog.getFile();
- dirName = dialog.getDirectory();
- if( fileName != null )
- {
- int index = fileName.indexOf( '.' );
- if( index == -1 )
- {
- fileName += ".html";
- }
- if( index == fileName.length() - 1 )
- {
- fileName += "html";
- }
- String fullName = dirName + fileName;
- String text = resultadoText.getText();
- String title = "S.I.P.R.P. - Sociedade Ibérica de Prevenção de Riscos Profissionais";
- String style = "";
- text = text.replace( "", "\n\t\t" + title + "\n" + style );
- text = text.replace( "", "" );
- text = text.replace( "", "
" );
-// System.out.println( text );
- try
- {
- FileWriter writer = new FileWriter( new File( fullName ) );
- writer.write( text );
- writer.close();
- }
- catch( IOException ex )
- {
- DialogException.showException( ex );
- return;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java
deleted file mode 100644
index f4e6c2c5..00000000
--- a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * EmpresaPanel.java
- *
- * Created on 29 de Marco de 2004, 11:53
- */
-
-package siprp.ficha;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Map;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import shst.SHSTPropertiesConstants;
-import shst.data.outer.EmpresasData;
-import shst.data.outer.EstabelecimentosData;
-import siprp.FichaDataProvider;
-
-import com.evolute.entity.ProviderInterface;
-import com.evolute.utils.Singleton;
-import com.evolute.utils.data.IDObject;
-import com.evolute.utils.data.MappableObject;
-import com.evolute.utils.dataui.ComponentController;
-import com.evolute.utils.dataui.ComponentsHashtable;
-import com.evolute.utils.dataui.ControllableComponent;
-import com.evolute.utils.ui.DialogException;
-import com.evolute.utils.ui.panel.RadioButtonFixedPanel;
-import com.evolute.utils.ui.panel.RadioButtonPanel;
-import com.evolute.utils.ui.text.CopyPasteHandler;
-
-/**
- *
- * @author fpalma
- */
-public class EmpresaPanel extends JPanel
- implements ControllableComponent< Object >
-{
- private ProviderInterface JDO;
- private JTextField designacaoSocialText;
- private JTextField estabelecimentoText;
- private JTextField localidadeText;
- private RadioButtonFixedPanel servicoSaudeTipoPanel;
- private JTextField designacaoServicoSaudeText;
- private JButton defaultServicoSaudeButton;
- private RadioButtonFixedPanel servicoHigieneTipoPanel;
- private JTextField designacaoText;
- private JButton defaultServicoHigieneButton;
-
- private FichaDataProvider provider;
- private ComponentsHashtable empresaComponents;
- private ComponentsHashtable estabelecimentoComponents;
-
- private EstabelecimentosData estabelecimento;
- private EmpresasData empresa;
-
-
- /** Creates a new instance of EmpresaPanel */
- public EmpresaPanel()
- throws Exception
- {
- provider = (FichaDataProvider)FichaDataProvider.getProvider();
- JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
- setupComponents();
- setupComponentsHashtable();
- }
-
- private void setupComponents()
- {
- setBorder( BorderFactory.createTitledBorder(
- BorderFactory.createEtchedBorder(),
- "Empresa/Entidade" ) );
-
- JLabel designacaoSocialLabel = new JLabel( "Designa\u00e7\u00e3o Social" );
- designacaoSocialText = new JTextField();
-// JPanel servicoSaudePanel = new JPanel();
- JLabel estabelecimentoLabel = new JLabel( "Estabelecimento" );
- estabelecimentoText = new JTextField();
- JLabel localidadeLabel = new JLabel( "Localidade" );
- localidadeText = new JTextField();
- JLabel servicoSaudeLabel = new JLabel( "Servi\u00e7o de Sa\u00fade: Tipo" );
- servicoSaudeTipoPanel =
- new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ),
- new MappableObject( new Integer(2), "Interempresas" ),
- new MappableObject( new Integer(3), "Externo" ),
- new MappableObject( new Integer(4), "Servi\u00e7o Nacional de Sa\u00fade" ) },
- 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
- JLabel designacaoServicoSaudeLabel = new JLabel( "Designa\u00e7\u00e3o" );
- designacaoServicoSaudeText = new JTextField();
- defaultServicoSaudeButton = new JButton("-");
- defaultServicoSaudeButton.addActionListener( new ActionListener(){
- public void actionPerformed( ActionEvent e )
- {
- designacaoServicoSaudeText.setText( (String) Singleton.getInstance( SHSTPropertiesConstants.COMPANY_NAME ) );
- }
- } );
-
- JLabel servicoHigieneLabel = new JLabel( "Servi\u00e7o de Higiene e Seguran\u00e7a: Tipo" );
- servicoHigieneTipoPanel =
- new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ),
- new MappableObject( new Integer(2), "Interempresas" ),
- new MappableObject( new Integer(3), "Externo" ),
- new MappableObject( new Integer(4), "Outro" ) },
- 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
- JLabel designacaoLabel = new JLabel( "Designa\u00e7\u00e3o" );
- designacaoText = new JTextField();
- defaultServicoHigieneButton = new JButton("-");
- defaultServicoHigieneButton.addActionListener( new ActionListener(){
- public void actionPerformed( ActionEvent e )
- {
- designacaoText.setText( (String) Singleton.getInstance( SHSTPropertiesConstants.COMPANY_NAME ) );
- }
- } );
-
- GridBagLayout gridbag = new GridBagLayout();
- setLayout( gridbag );
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.insets = new Insets( 0, 1, 0, 1 );
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.gridwidth = 1;
- constraints.weightx = 0;
- constraints.gridheight = 1;
- constraints.weighty = 0;
-
- gridbag.setConstraints( designacaoSocialLabel, constraints );
- add( designacaoSocialLabel );
-
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( designacaoSocialText, constraints );
- add( designacaoSocialText );
-
- constraints.weightx = 0;
- constraints.gridwidth = 1;
- gridbag.setConstraints( estabelecimentoLabel, constraints );
- add( estabelecimentoLabel );
-
- constraints.weightx = 0.6;
- constraints.gridwidth = 3;
- gridbag.setConstraints( estabelecimentoText, constraints );
- add( estabelecimentoText );
-
- constraints.weightx = 0;
- constraints.gridwidth = 1;
- gridbag.setConstraints( localidadeLabel, constraints );
- add( localidadeLabel );
-
- constraints.weightx = 0.4;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( localidadeText, constraints );
- add( localidadeText );
-
- constraints.weightx = 0;
- constraints.gridwidth = 2;
- gridbag.setConstraints( servicoSaudeLabel, constraints );
- add( servicoSaudeLabel );
-
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( servicoSaudeTipoPanel, constraints );
- add( servicoSaudeTipoPanel );
-
- constraints.weightx = 0;
- constraints.gridwidth = 1;
- gridbag.setConstraints( designacaoServicoSaudeLabel, constraints );
- add( designacaoServicoSaudeLabel );
-
- JPanel designacaoServicoSaudePanel = new JPanel();
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( designacaoServicoSaudePanel, constraints );
- add( designacaoServicoSaudePanel );
-
- constraints.weightx = 0;
- constraints.gridwidth = 3;
- gridbag.setConstraints( servicoHigieneLabel, constraints );
- add( servicoHigieneLabel );
-
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( servicoHigieneTipoPanel, constraints );
- add( servicoHigieneTipoPanel );
-
- constraints.gridwidth = 1;
- constraints.weightx = 0;
- constraints.weighty = 1;
- constraints.gridheight = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( designacaoLabel, constraints );
- add( designacaoLabel );
-
- JPanel designacaoServicoHigienePanel = new JPanel();
- constraints.weightx = 1;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( designacaoServicoHigienePanel, constraints );
- add( designacaoServicoHigienePanel );
-
- gridbag = new GridBagLayout();
- designacaoServicoSaudePanel.setLayout( gridbag );
- constraints.insets = new Insets( 0, 0, 0, 0 );
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.gridwidth = 1;
- constraints.weightx = 1;
- constraints.weighty = 1;
- constraints.gridheight = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints( designacaoServicoSaudeText, constraints );
- designacaoServicoSaudePanel.add( designacaoServicoSaudeText );
-
- constraints.weightx = 0;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( defaultServicoSaudeButton, constraints );
- designacaoServicoSaudePanel.add( defaultServicoSaudeButton );
-
-
- gridbag = new GridBagLayout();
- designacaoServicoHigienePanel.setLayout( gridbag );
- constraints.insets = new Insets( 0, 0, 0, 0 );
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.gridwidth = 1;
- constraints.weightx = 1;
- constraints.weighty = 1;
- constraints.gridheight = GridBagConstraints.REMAINDER;
-
- gridbag.setConstraints( designacaoText, constraints );
- designacaoServicoHigienePanel.add( designacaoText );
-
- constraints.weightx = 0;
- constraints.gridwidth = GridBagConstraints.REMAINDER;
- gridbag.setConstraints( defaultServicoHigieneButton, constraints );
- designacaoServicoHigienePanel.add( defaultServicoHigieneButton );
-
- new CopyPasteHandler( designacaoSocialText );
- new CopyPasteHandler( estabelecimentoText );
- new CopyPasteHandler( localidadeText );
- new CopyPasteHandler( designacaoServicoSaudeText );
- new CopyPasteHandler( designacaoText );
- }
-
- private void setupComponentsHashtable()
- {
- empresaComponents = new ComponentsHashtable();
- empresaComponents.putComponent( EmpresasData.DESIGNACAO_SOCIAL, designacaoSocialText );
- empresaComponents.putComponent( EmpresasData.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
- empresaComponents.putComponent( EmpresasData.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
- empresaComponents.putComponent( EmpresasData.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
- empresaComponents.putComponent( EmpresasData.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
-
- empresaComponents.putDummy( EmpresasData.MORADA );
- empresaComponents.putDummy( EmpresasData.CODIGO_POSTAL );
- empresaComponents.putDummy( EmpresasData.LOCALIDADE );
- empresaComponents.putDummy( EmpresasData.DISTRITO );
- empresaComponents.putDummy( EmpresasData.CONCELHO );
- empresaComponents.putDummy( EmpresasData.DATA_PROPOSTA );
- empresaComponents.putDummy( EmpresasData.DATA_ACEITACAO );
- empresaComponents.putDummy( EmpresasData.PERFIL_1 );
- empresaComponents.putDummy( EmpresasData.PERFIL_2 );
- empresaComponents.putDummy( EmpresasData.DATA_ENVIO_CONTRATO );
- empresaComponents.putDummy( EmpresasData.DATA_RECEPCAO_CONTRATO );
- empresaComponents.putDummy( EmpresasData.DATA_ENVIO_IDICT );
- empresaComponents.putDummy( EmpresasData.DATA_RELATORIO_ANUAL );
- empresaComponents.putDummy( EmpresasData.CODIGO_1 );
- empresaComponents.putDummy( EmpresasData.CODIGO_2 );
- empresaComponents.putDummy( EmpresasData.CODIGO_3 );
- empresaComponents.putDummy( EmpresasData.CAE );
- empresaComponents.putDummy( EmpresasData.ACTIVIDADE );
- empresaComponents.putDummy( EmpresasData.CONTRIBUINTE );
- empresaComponents.putDummy( EmpresasData.SEGURANCA_SOCIAL );
- empresaComponents.putDummy( EmpresasData.CONTACTO_1 );
- empresaComponents.putDummy( EmpresasData.CONTACTO_2 );
- empresaComponents.putDummy( EmpresasData.SERVICOS );
-// empresaComponents.putDummy( EmpresasData.PRECO_HIGIENE );
-// empresaComponents.putDummy( EmpresasData.PRECO_MEDICINA );
- empresaComponents.putDummy( EmpresasData.PERIODICIDADE );
- empresaComponents.putDummy( EmpresasData.DESIGNACAO_SOCIAL_PLAIN );
- empresaComponents.putDummy( EmpresasData.DATA_CANCELAMENTO );
- empresaComponents.putDummy( EmpresasData.A_CONSULTAS );
- empresaComponents.putDummy( EmpresasData.A_EXAMES );
- empresaComponents.putDummy( EmpresasData.B_CONSULTAS );
- empresaComponents.putDummy( EmpresasData.B_EXAMES );
- empresaComponents.putDummy( EmpresasData.INICIO_CONTRATO );
- empresaComponents.putDummy( EmpresasData.DURACAO );
-
- estabelecimentoComponents = new ComponentsHashtable();
- estabelecimentoComponents.putComponent( EstabelecimentosData.NOME, estabelecimentoText );
- estabelecimentoComponents.putComponent( EstabelecimentosData.LOCALIDADE, localidadeText );
- estabelecimentoComponents.putDummy( EstabelecimentosData.MORADA );
- estabelecimentoComponents.putDummy( EstabelecimentosData.CODIGO_POSTAL );
- estabelecimentoComponents.putDummy( EstabelecimentosData.CONTACTO_ID );
- estabelecimentoComponents.putDummy( EstabelecimentosData.HISTORICO );
- estabelecimentoComponents.putDummy( EstabelecimentosData.EMPRESA_ID );
- estabelecimentoComponents.putDummy( EstabelecimentosData.NOME_PLAIN );
-
-// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.DESIGNACAO_SOCIAL, designacaoSocialText );
-// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
-// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
-// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
-// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
-//
-// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.NOME, estabelecimentoText );
-// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.LOCALIDADE, localidadeText );
-//
-// components.putDummy( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.INACTIVO );
-// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.EMPRESA_ID );
-// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.INACTIVO );
- }
-
- public void fill(Object value)
- {
- clear();
- empresa = null;
- estabelecimento = null;
- if( value != null )
- {
- Integer empresaID = (Integer)((Object[])value)[0];
- Integer estabelecimentoID = (Integer)((Object[])value)[1];
- if( empresaID != null )
- {
- try
- {
- empresa = (EmpresasData)JDO.load( EmpresasData.class, empresaID );
- String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
- ComponentController.fill( names, empresa.getHashData(), empresaComponents );
-
- if( estabelecimentoID != null )
- {
- estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentoID );
- names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] ); //estabelecimento.getFieldNames();
- ComponentController.fill( names, estabelecimento.getHashData(), estabelecimentoComponents );
- }
-
-// DBField fields[] = provider.EMPRESAS.getInsertFields();
-// String empresaFields[] = new String[ fields.length ];
-// Hashtable data = new Hashtable();
-// for( int i = 0; i < empresaFields.length; ++i )
-// {
-// empresaFields[ i ] = fields[ i ].FULL_NAME;
-// Object fieldValue = empresa.getProperty( empresaFields[ i ] );
-// if( fieldValue != null )
-// {
-// data.put( empresaFields[ i ], fieldValue );
-// }
-// }
-// ComponentController.fill( empresaFields, data, components );
-// if( estabelecimentoID != null )
-// {
-// estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) );
-// fields = provider.ESTABELECIMENTOS.getInsertFields();
-// String estabelecimentoFields[] = new String[ fields.length ];
-// for( int i = 0; i < estabelecimentoFields.length; ++i )
-// {
-// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
-// Object fieldValue = estabelecimento.getProperty( estabelecimentoFields[ i ] );
-// if( fieldValue != null )
-// {
-// data.put( estabelecimentoFields[ i ], fieldValue );
-// }
-// }
-// ComponentController.fill( estabelecimentoFields, data, components );
-// }
- }
- catch( Exception ex )
- {
- DialogException.showExceptionMessage( ex, "Erro a carregar os dados da Empresa", true );
- }
- }
- }
- else
- {
- estabelecimentoText.setText( "Sede" );
- }
- }
-
- public Object save()
- {
- StringBuffer msg = new StringBuffer();
- boolean hasMsg = false;
- try
- {
- if( estabelecimento == null )
- {
-// estabelecimento = provider.createObject( provider.ESTABELECIMENTOS );
- estabelecimento = new EstabelecimentosData();
- }
- if( empresa == null )
- {
-// empresa = provider.createObject( provider.EMPRESAS );
- empresa = new EmpresasData();
- }
-// DBField fields[] = provider.EMPRESAS.getInsertFields();
-// String empresaFields[] = new String[ fields.length ];
-// for( int i = 0; i < empresaFields.length; ++i )
-// {
-// empresaFields[ i ] = fields[ i ].FULL_NAME;
-// }
-// Hashtable hash = new Hashtable();
-// ComponentController.save( empresaFields, hash, components );
-// Enumeration enum = hash.keys();
-// while( enum.hasMoreElements() )
-// {
-// String name = ( String )enum.nextElement();
-// empresa.setProperty( name, hash.get( name ) );
-// }
-// fields = provider.ESTABELECIMENTOS.getInsertFields();
-// String estabelecimentoFields[] = new String[ fields.length ];
-// for( int i = 0; i < estabelecimentoFields.length; ++i )
-// {
-// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
-// }
-// hash = new Hashtable();
-// ComponentController.save( estabelecimentoFields, hash, components );
-// enum = hash.keys();
-// while( enum.hasMoreElements() )
-// {
-// String name = ( String )enum.nextElement();
-// estabelecimento.setProperty( name, hash.get( name ) );
-// }
-
- String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
-// String names[] = new String[]{ EmpresasData.DESIGNACAO_SOCIAL, EmpresasData.SERVICO_SAUDE_TIPO,
-// EmpresasData.SERVICO_SAUDE_DESIGNACAO, EmpresasData.SERVICO_HIGIENE_TIPO,
-// EmpresasData.SERVICO_HIGIENE_DESIGNACAO };
- Map hash = empresa.getHashData();
- ComponentController.save( names, hash, empresaComponents );
- empresa.setHashData( hash );
-
-// names = estabelecimento.getFieldNames();
- names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
- hash = estabelecimento.getHashData();
- ComponentController.save( names, hash, estabelecimentoComponents );
- estabelecimento.setHashData( hash );
- estabelecimento.setToEmpresa_id( empresa );
-
-// estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
-
-// if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 )
- if( ((String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL )).trim().length() == 0 )
- {
- msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" );
- hasMsg = true;
- }
- else
- {
- empresa.set( EmpresasData.DESIGNACAO_SOCIAL_PLAIN,
- com.evolute.utils.strings.StringPlainer.convertString( ( String )
- empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) ) );
- }
-// if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null )
- if( empresa.get( EmpresasData.SERVICO_SAUDE_TIPO ) == null )
- {
- msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" );
- hasMsg = true;
- }
-// if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null )
- if( empresa.get( EmpresasData.SERVICO_HIGIENE_TIPO ) == null )
- {
- msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" );
- hasMsg = true;
- }
-// if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 )
- if( ((String)estabelecimento.get( EstabelecimentosData.NOME )).trim().length() == 0 )
- {
- msg.append( "O estabelecimento tem de ter nome\n" );
- hasMsg = true;
- }
-
- }
- catch( Exception ex )
- {
- ex.printStackTrace();
- return null;
- }
- if( hasMsg )
- {
- throw new ValuesException( msg.toString() );
- }
- return estabelecimento;
-
- }
-
- public void clear()
- {
- String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
- ComponentController.clear( names, empresaComponents );
- names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
- ComponentController.clear( names, estabelecimentoComponents );
- estabelecimentoText.setText( "Sede" );
- empresa = null;
- estabelecimento = null;
- }
-
- public void setEnabled( boolean enable )
- {
- String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
- ComponentController.setEnabled( names, enable, empresaComponents );
- names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
- ComponentController.setEnabled( names, enable, estabelecimentoComponents );
- }
-}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java
deleted file mode 100644
index 56dc759f..00000000
--- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java
+++ /dev/null
@@ -1,524 +0,0 @@
-package siprp.ficha;
-
-import java.awt.Color;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.HashMap;
-
-import shst.SHSTPropertiesConstants;
-
-import com.evolute.utils.Singleton;
-import com.lowagie.text.Cell;
-import com.lowagie.text.Chunk;
-import com.lowagie.text.Document;
-import com.lowagie.text.Element;
-import com.lowagie.text.Font;
-import com.lowagie.text.FontFactory;
-import com.lowagie.text.PageSize;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.Table;
-import com.lowagie.text.pdf.BaseFont;
-import com.lowagie.text.pdf.PdfWriter;
-
-public class ExamePDF implements FichaAptidaoConstants
-{
- private final Font FONT_BOLD = FontFactory.getFont( "Arial", 8, Font.BOLD );
- private final Font FONT_NORMAL = FontFactory.getFont( "Arial", 8, Font.NORMAL );
- private final Font FONT_ZAPFDINGBATS = new Font( Font.ZAPFDINGBATS , 12, Font.NORMAL, new Color( 0, 0, 0 ) );
-
- private BaseFont BASE_WINGDINGS;
- private Font FONT_WINGDINGS;
-
-// static
-// {
-// try
-// {
-// //BASE_WINGDINGS = BaseFont.createFont("C:\\WINNT\\Fonts\\WINGDING.TTF", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
-// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED);
-// InputStream stream = BaseFont.getResourceStream( "WING", ClassLoader loader)
-// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED,
-// true, byte[] ttfAfm, null );
-// FONT_WINGDINGS = new Font(BASE_WINGDINGS, 12);
-// }
-// catch( Exception ex )
-// {
-// FONT_WINGDINGS = FONT_NORMAL;
-// System.out.println( "NO FONT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
-// }
-// }
-
- public ExamePDF()
- {
- FontFactory.registerDirectories();
- String possibleNames[] = new String[]{ "Wingdings", "WingDings", "wingdings", "WINGDINGS" };
-
- for( int n = 0; n < 4; n++ )
- {
- FONT_WINGDINGS = FontFactory.getFont( possibleNames[ n ] );
- if( FONT_WINGDINGS.getFamilyname().toLowerCase().equals( "wingdings" ) )
- {
- break;
- }
- }
-
- }
-
- public static void main( String[] args )
- {
- try
- {
- HashMap ht = new HashMap();
- // designacao_social
- // estabelecimentos.nome
- // estabelecimentos.localidade
- // servico_saude_tipo_interno
- // servico_saude_tipo_interempresas
- // servico_saude_tipo_externo
- // servico_saude_tipo_sns
- // servico_saude_designacao
- // servico_higiene_tipo_interno
- // servico_higiene_tipo_interempresas
- // servico_higiene_tipo_externo
- // servico_higiene_outro
- // servico_higiene_designacao
- // trabalhadores.nome
- // sexo
- // data_nascimento
- // nacionalidade
- // numero_mecanografico
- // data_admissao
- // categoria
- // local_trabalho
- // funcao_proposta
- // data_admissao_funcao
- // observacoes
- // exames.data
- // tipo_admissao
- // tipo_periodico
- // tipo_ocasional
- // tipo_apos_doenca
- // tipo_apos_acidente
- // tipo_pedido_trabalhador
- // tipo_pedido_empresa
- // tipo_mudanca_funcao
- // tipo_trabalho
- // tipo_outro
- // resultado_apto
- // resultado_apto_condicionalmente
- // resultado_inapto_temp
- // resultado_inapto_def
- // outra_funcao_1
- // outra_funcao_2
- // outra_funcao_3
- // outra_funcao_4
- // proximo_exame
- // outras_recomendacoes
- // medicos.nome
- // numero_cedula
-
- ht.put( TRABALHADORES_NOME, "Trabalhador do com\u00e9rcio" );
- ht.put( SERVICO_SAUDE_DESIGNACAO, "Designacao servico saude" );
- ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "" + Boolean.TRUE );
- ht.put( TIPO_PERIODICO, "" + Boolean.TRUE );
- ht.put( RESULTADO_INAPTO_TEMP, "" + Boolean.TRUE );
- FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report.pdf" );
- fos.write( new ExamePDF().createPDF( ht ) );
- fos.close();
- System.out.println( "File saved." );
- Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report.pdf\"" );
- proc.waitFor();
- new File( System.getProperty( "user.home" ) + "\\report.pdf" ).delete();
- System.out.println( "Done." );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
-
- public void print( byte []pdf, String nome )
- throws Exception
- {
-// new PDFFilePrinter( pdf, false );
-
-// if( true )
-// {
-// return;
-// }
-
- long time = System.currentTimeMillis();
-// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
- FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
- fos.write( pdf );
- fos.close();
- System.out.println( "File saved ( " + nome + "_" + time + " )." );
- Process proc;
- if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
- {
-//System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
- proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\"" );
-
-// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\open.bat", System.getProperty( "user.home" ) + "\\" + nome + "_" + time + ".pdf" });
-
-
- proc.waitFor();
- if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ).delete() )
- {
- System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" );
- }
- }
- else
- {
-//System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
- try{
- proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" } );
- }
- catch( Exception ex )
- {
- ex.printStackTrace();
- }
-// proc = Runtime.getRuntime().exec( "/usr/bin/open \"/Users/Shared/teste.pdf.pdf\"" );
- }
- }
-
- public void printSilent( byte []pdf, String nome, String printerName ) throws InterruptedException, IOException
- // throws Exception
- {
- long time = System.currentTimeMillis();
-// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
-
- if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
- {
- Process proc;
-
-// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf" );
- FileOutputStream fos = new FileOutputStream( "c:\\temp\\" + nome + "_" + time + ".pdf" );
- fos.write( pdf );
- fos.close();
-
- System.out.println( "File saved ( " + nome + "_" + time + " )." );
-//System.out.println("cmd /c \"c:\\temp\\acrord32.lnk /t \"c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\" \"" + printerName + "\"\"");
-// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
-// System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf",
-// printerName });
- proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
- "c:\\temp\\" + nome + "_" + time + ".pdf",
- printerName });
- proc.waitFor();
-// if( !new File( "c:\\temp\\" + nome + "_" + time + ".pdf" ).delete() )
-// {
-// System.err.println( "File: " + nome + "_" + ".pdf - NOT DELETED" );
-// }
- }
-
- }
-
- public void cleanSilentPrint()
- throws Exception
- {
- Process proc;
- proc = Runtime.getRuntime().exec( "cmd /c \"del c:\\temp\\*.pdf\"" );
- proc.waitFor();
- }
-
- public byte[] createPDF( HashMap values )
- {
- Document document = new Document();
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- document.setPageSize( PageSize.A4 );
- try {
- PdfWriter pdfw = PdfWriter.getInstance( document, bos );
-// try {
-
-
- document.addTitle( "Ficha de Aptid\u00e3o" );
- String acronym = (String) Singleton.getInstance( SHSTPropertiesConstants.COMPANY_ACRONYM );
- document.addAuthor( acronym != null ? acronym: "n/a" );
- document.addCreator( "Evolute" );
-
- document.open();
-
- Paragraph conteudo = new Paragraph();
-
- conteudo.add( new Chunk( "\n\nFICHA DE APTID\u00c3O\n",
- FontFactory.getFont( "Arial", 10, Font.BOLD ) ) );
- conteudo.add( new Chunk( "(Portaria n.\u00ba 299/2007, de 16 de Mar\u00e7o)",
-// conteudo.add( new Chunk( "(Portaria n\u00ba1031/2002, de 10 de Agosto)",
- FontFactory.getFont( "Arial", 7, Font.BOLD ) ) );
-
- conteudo.setAlignment( Element.ALIGN_CENTER );
-
- document.add( conteudo );
-
- Table table = new Table( 1 );
- table.setBorderWidth( 1 );
- table.setPadding( 5 );
- table.setOffset( 0 );
- table.setWidth( 100 );
-
- table.addCell( new Phrase( "Empresa/Entidade", FONT_BOLD ) );
-
- StringBuilder texto = new StringBuilder();
- Phrase ph = new Phrase( 12f );
-
- Cell cell = new Cell();
- texto.append( "DESIGNA\u00c7\u00c3O SOCIAL: " + values.get( DESIGNACAO_SOCIAL ) + "\n" );
- texto.append( "ESTABELECIMENTO: " + values.get( ESTABELECIMENTOS_NOME )
- + " LOCALIDADE: " + values.get( ESTABELECIMENTOS_LOCALIDADE ) + "\n" );
- texto.append( "SERVI\u00c7O DE SA\u00DaDE: Tipo " );
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
-
- texto = new StringBuilder( "Interno" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTERNO ) ) );
-
- texto = new StringBuilder( "Interempresas" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTEREMPRESAS ), true ) );
-
- texto = new StringBuilder( "Externo" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_EXTERNO ), true ) );
-
- texto = new StringBuilder( "Servi\u00e7o Nacional de Sa\u00fade\n" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_SNS ), true ) );
-
- texto = new StringBuilder();
-
- texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_SAUDE_DESIGNACAO ) + "\n" );
- texto.append( "SERVI\u00c7O DE HIGIENE E SEGURAN\u00c7A: Tipo " );
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
-
- texto = new StringBuilder( "Interno" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTERNO ) ) );
-
- texto = new StringBuilder( "Interempresas" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTEREMPRESAS ), true ) );
-
- texto = new StringBuilder( "Externo" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_EXTERNO ), true ) );
-
- texto = new StringBuilder( "Outro\n" );
- ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_OUTRO ), true ) );
-
- texto = new StringBuilder();
-
- texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_HIGIENE_DESIGNACAO ) + "" );
-
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
-
- cell.addElement( ph );
- table.addCell( cell );
- document.add( table );
-
- table = new Table( 1 );
- table.setBorderWidth( 1 );
- table.setPadding( 5 );
- table.setOffset( 0 );
- table.setWidth( 100 );
-
- table.addCell( new Phrase( "Trabalhador",
- FONT_BOLD ) );
-
- texto = new StringBuilder();
-
- texto.append( "NOME: " + values.get( TRABALHADORES_NOME ) + "\n" );
- texto.append( "SEXO: " + values.get( SEXO ) + " DATA DE NASCIMENTO: "
- + values.get( DATA_NASCIMENTO ) + " NACIONALIDADE: "
- + values.get( NACIONALIDADE ) + "\n" );
- texto.append( "N\u00daMERO MECANOGR\u00c1FICO/OUTRO: " + values.get( NUMERO_MECANOGRAFICO )
- + " DATA DE ADMISS\u00c3O: " + values.get( DATA_ADMISSAO ) + "\n" );
- texto.append( "CATEGORIA PROFISSIONAL: " + values.get( CATEGORIA )
- + " LOCAL DE TRABALHO: " + values.get( LOCAL_TRABALHO ) + "\n" );
- texto.append( "FUN\u00c7\u00c3O PROPOSTA: " + values.get( FUNCAO_PROPOSTA )
- + " DATA DE ADMISS\u00c3O NA FUN\u00c7\u00c3O: "
- + values.get( DATA_ADMISSAO_FUNCAO ) + "" );
-
- table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
- document.add( table );
-
- table = new Table( 1 );
- table.setBorderWidth( 1 );
- table.setOffset( 0 );
- table.setPadding( 5 );
- table.setWidth( 100 );
-
- table.addCell( new Phrase( "Observa\u00e7\u00f5es",
- FONT_BOLD ) );
-
- texto = new StringBuilder();
- texto.append( values.get( OBSERVACOES ) );
-
- table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
- document.add( table );
-
- table = new Table( 2 );
- table.setBorderWidth( 1 );
- table.setOffset( 0 );
- table.setPadding( 5 );
- table.setWidth( 100 );
-
- cell = new Cell( new Phrase( "Exame M\u00e9dico",
- FONT_BOLD ) );
-
- cell.setColspan( 2 );
- table.addCell( cell );
-
- texto = new StringBuilder();
- ph = new Phrase( 12f );
- texto.append( "DATA DO EXAME: " + values.get( EXAMES_DATA ) + "\n" );
- texto.append( "TIPO\n" );
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
-
- ph.add( doCheckedPhrase( "ADMISS\u00c3O\n", values.get( TIPO_ADMISSAO ) ) );
-
- ph.add( doCheckedPhrase( "PERI\u00d3DICO\n", values.get( TIPO_PERIODICO ) ) );
-
- ph.add( doCheckedPhrase( "OCASIONAL\n", values.get( TIPO_OCASIONAL ) ) );
-
- ph.add( doCheckedPhrase( "AP\u00d3S DOEN\u00c7A\n", values.get( TIPO_APOS_DOENCA ), true ) );
-
- ph.add( doCheckedPhrase( "AP\u00d3S ACIDENTE\n", values.get( TIPO_APOS_ACIDENTE ), true ) );
-
- ph.add( doCheckedPhrase( "A PEDIDO DO TRABALHADOR\n", values.get( TIPO_PEDIDO_TRABALHADOR ), true ) );
-
- ph.add( doCheckedPhrase( "A PEDIDO DO SERVI\u00c7O\n", values.get( TIPO_PEDIDO_EMPRESA ), true ) );
-
- ph.add( doCheckedPhrase( "POR MUDAN\u00c7A DE FUN\u00c7\u00c3O\n", values.get( TIPO_MUDANCA_FUNCAO ), true ) );
-
- ph.add( doCheckedPhrase( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n", values.get( TIPO_TRABALHO ), true ) );
-
- ph.add( doCheckedPhrase( "OUTRO\n", values.get( TIPO_OUTRO ), true ) );
-
- texto = new StringBuilder();
- texto.append( " ESPECIFIQUE: " + values.get( TIPO_OUTRO_TEXTO ) );
-
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
-
- table.addCell( ph );
-
- ph = new Phrase( 12f );
- ph.add( new Chunk( "RESULTADO\n", FONT_NORMAL ) );
- ph.add( doCheckedPhrase( "APTO\n", values.get( RESULTADO_APTO ) ) );
-
- ph.add( doCheckedPhrase( "APTO CONDICIONALMENTE\n\n", values.get( RESULTADO_APTO_CONDICIONALMENTE ) ) );
-
- ph.add( doCheckedPhrase( "INAPTO TEMPORARIAMENTE\n", values.get( RESULTADO_INAPTO_TEMP ) ) );
-
- ph.add( doCheckedPhrase( "INAPTO DEFINITIVAMENTE\n\n", values.get( RESULTADO_INAPTO_DEF ) ) );
-
- texto = new StringBuilder();
- texto.append( "OUTRAS FUN\u00c7\u00d5ES QUE PODE DESEMPENHAR\n" );
- texto.append( " 1 " + values.get( OUTRA_FUNCAO_1 ) + "\n" );
- texto.append( " 2 " + values.get( OUTRA_FUNCAO_2 ) + "\n" );
- texto.append( " 3 " + values.get( OUTRA_FUNCAO_3 ) + "\n" );
- texto.append( " 4 " + values.get( OUTRA_FUNCAO_4 ) + "\n" );
- ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
- table.addCell( ph );
-
- document.add( table );
-
- table = new Table( 1 );
- table.setBorderWidth( 1 );
- table.setOffset( 0 );
- table.setPadding( 5 );
- table.setWidth( 100 );
-
- table.addCell( new Phrase( "Outras Recomenda\u00e7\u00f5es",
- FONT_BOLD ) );
-
- texto = new StringBuilder();
- if( ( (Boolean) Singleton.getInstance( SHSTPropertiesConstants.FICHA_MARCA_EXAMES ) ).booleanValue() )
- {
- System.out.println( "ficha marca exames" );
- texto.append( "PR\u00d3XIMO EXAME: " + values.get( PROXIMO_EXAME ) + "\n" );
- }
- texto.append( "" + values.get( OUTRAS_RECOMENDACOES ) + "" );
-
- table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
- document.add( table );
-
-
- table = new Table( 1 );
- table.setBorderWidth( 1 );
- table.setOffset( 0 );
- table.setPadding( 5 );
- table.setWidth( 100 );
-
- texto = new StringBuilder();
-
- texto.append( "M\u00c9DICO DO TRABALHO: "
- + values.get( MEDICOS_NOME ) + " C.P. " + values.get( NUMERO_CEDULA ) + "\n" );
- texto.append( "ASSINATURA _____________________________________________________________________________________\n\n" );
- texto.append( "TOMEI CONHECIMENTO ___________________________________________________________ DATA:____/____/________\n" );
- texto.append( " O RESPONS\u00c1VEL DOS RECURSOS HUMANOS" );
-
- table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) );
- document.add( table );
-
-// }
-// catch( Exception e ) {
-// e.printStackTrace();
-// return null;
-// }
-
- document.close();
-// PdfWriter pdfw = PdfWriter.getInstance( document, bos );
-// PdfContentByte pdfcb = new PdfContentByte( pdfw );
-//
-// PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
-// // Step 2: Obtain a print job.
-// PrinterJob pj = PrinterJob.getPrinterJob();
-// Graphics2D graphics = pdfcb.createPrinterGraphics( 100.0F, 100.0F, pj );
-// // Step 3: Find print services.
-// PrintService []services = PrinterJob.lookupPrintServices();
-// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
-// if(services.length > 0)
-// {
-// System.out.println("selected printer: " + services[0]);
-// try
-// {
-// PrintService service = defaultService;
-//// PrintService service = ServiceUI.printDialog(null, 200, 200,
-//// services, defaultService, DocFlavor.SERVICE_FORMATTED.PAGEABLE, aset);
-// pj.setPrintService(service);
-// // Step 2: Pass the settings to a page dialog and print dialog.
-//// pj.pageDialog(aset);
-//// if (pj.printDialog(aset))
-//// {
-// // Step 4: Update the settings made by the user in the dialogs.
-// // Step 5: Pass the final settings into the print request.
-// pj.print(aset);
-//// }
-// }
-// catch (PrinterException pe ) {
-// System.err.println(pe);
-// }
-// }
-
- }
- catch( Exception e ) {
- e.printStackTrace();
- return null;
- }
- return bos.toByteArray();
- }
-
- private Phrase doCheckedPhrase( String text, String phrase, boolean indent )
- {
- boolean checked = CHECKED.equals( phrase );
- Phrase p = new Phrase( 12f );
- //p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) );
- //System.out.println( "FAMILY: " + FONT_WINGDINGS.getFamilyname() );
- p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 0xfe: 0xa8), FONT_WINGDINGS ) );
-// p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 'X': '_'), FONT_WINGDINGS ) );
- p.add( new Chunk( text, FONT_NORMAL ) );
- return p;
- }
-
- private Phrase doCheckedPhrase( String text, String phrase )
- {
- return doCheckedPhrase( text, phrase, false );
- }
-}
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java
deleted file mode 100644
index ae8ff047..00000000
--- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * ExamePanel.java
- *
- * Created on 29 de Marco de 2004, 11:57
- */
-
-package siprp.ficha;
-
-import java.awt.BorderLayout;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Vector;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.ListSelectionListener;
-
-import shst.MedicinaConstants;
-import shst.SHSTPropertiesConstants;
-import shst.data.Marcacao;
-import shst.data.outer.ExamesData;
-import shst.data.outer.MarcacoesTrabalhadorData;
-import siprp.FichaDataProvider;
-
-import com.evolute.entity.ProviderInterface;
-import com.evolute.utils.Singleton;
-import com.evolute.utils.data.IDObject;
-import com.evolute.utils.data.MappableObject;
-import com.evolute.utils.dataui.ComponentController;
-import com.evolute.utils.dataui.ComponentsHashtable;
-import com.evolute.utils.dataui.ControllableComponent;
-import com.evolute.utils.documents.MaximumLengthDocument;
-import com.evolute.utils.ui.button.BetterButtonGroup;
-import com.evolute.utils.ui.calendar.JCalendarPanel;
-import com.evolute.utils.ui.panel.RadioButtonFixedPanel;
-import com.evolute.utils.ui.text.CopyPasteHandler;
-/**
- *
- * @author fpalma
- */
-public class ExamePanel extends JPanel
- implements ChangeListener, ControllableComponent