forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1323 lines
47 KiB
1323 lines
47 KiB
/*
|
|
* EstatisticaWindow.java
|
|
*
|
|
* Created on 16 de Dezembro de 2004, 13:50
|
|
*/
|
|
|
|
package siprp.estatistica;
|
|
|
|
import java.awt.*;
|
|
import java.awt.event.*;
|
|
import java.io.*;
|
|
import javax.swing.*;
|
|
import javax.swing.event.*;
|
|
import java.text.*;
|
|
import java.util.*;
|
|
|
|
import com.evolute.utils.*;
|
|
import com.evolute.utils.data.*;
|
|
import com.evolute.utils.documents.*;
|
|
import com.evolute.utils.jdo.*;
|
|
import com.evolute.utils.tables.*;
|
|
import com.evolute.utils.tracker.*;
|
|
import com.evolute.utils.ui.*;
|
|
import com.evolute.utils.ui.text.*;
|
|
|
|
import siprp.data.*;
|
|
import siprp.pesquisas.*;
|
|
/**
|
|
*
|
|
* @author fpalma
|
|
*/
|
|
public class EstatisticaWindow extends JFrame
|
|
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 JDOProvider 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 = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_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.setBorder( BorderFactory.createTitledBorder(
|
|
BorderFactory.createEtchedBorder(), "Empresa" ) );
|
|
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.setBorder( BorderFactory.createTitledBorder(
|
|
BorderFactory.createEtchedBorder(), "Estabelecimento" ) );
|
|
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;
|
|
gridbag.setConstraints( empresasScroll, constraints );
|
|
getContentPane().add( empresasScroll );
|
|
|
|
gridbag.setConstraints( estabelecimentosScroll, constraints );
|
|
getContentPane().add( estabelecimentosScroll );
|
|
|
|
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;
|
|
gridbag.setConstraints( resultadoScroll, constraints );
|
|
getContentPane().add( resultadoScroll );
|
|
|
|
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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ LISTAGEM_GERAL_MARCACOES_PERIODO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EXAMES:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + exames + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "CONSULTAS:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + consultas + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "TOTAL:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + ( exames + consultas ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>EMPRESA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>NOME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>DATA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I> </I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getMarcacoesPeriodo( inicio, fim );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 0; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
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();
|
|
EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
|
|
String designacao = (String)empresa.get( EmpresaData.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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EMPRESA:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + designacao + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EXAMES:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + examesEmpresa + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "CONSULTAS:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + consultasEmpresa + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "TOTAL:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + ( examesEmpresa + consultasEmpresa ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
for( int e = 0; e < estabelecimentos.length; e++ )
|
|
{
|
|
EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
|
|
String nome = (String)estabelecimento.get( EstabelecimentoData.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( "<P><BR><BR></P>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "ESTABELECIMENTO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + nome + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EXAMES:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + exames + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "CONSULTAS:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + consultas + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "TOTAL:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + ( exames + consultas ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>NOME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>DATA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I> </I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getMarcacoesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 1; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
}
|
|
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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES : LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "TOTAL:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + count + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>EMPRESA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>N\u00ba</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ 0 ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + data[ l ][ 1 ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
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();
|
|
EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
|
|
String designacao = (String)empresa.get( EmpresaData.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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EMPRESA:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + designacao + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "Nº DE TRABALHADORES:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + countEmpresa + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
for( int e = 0; e < estabelecimentos.length; e++ )
|
|
{
|
|
EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
|
|
String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
|
|
int countEstabelecimento = provider.countTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
|
|
buffer.append( "<P><BR><BR></P>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "ESTABELECIMENTO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + nome + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "Nº DE TRABALHADORES:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + countEstabelecimento + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>NOME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 0; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
}
|
|
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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO : LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "TOTAL:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + count + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>EMPRESA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>N\u00ba</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ 0 ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + data[ l ][ 1 ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
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();
|
|
EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
|
|
String designacao = (String)empresa.get( EmpresaData.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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "EMPRESA:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + designacao + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "Nº:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + countEmpresa + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "</TABLE>" );
|
|
for( int e = 0; e < estabelecimentos.length; e++ )
|
|
{
|
|
EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
|
|
String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
|
|
int countEstabelecimento = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
|
|
buffer.append( "<P><BR><BR></P>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "ESTABELECIMENTO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + nome + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "Nº:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + countEstabelecimento + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>NOME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 0; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
}
|
|
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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ LISTAGEM_GLOBAL_TRABALHADORES_PERIODO ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD>" );
|
|
buffer.append( "PER\u00cdODO:" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD ALIGN=\"right\">" );
|
|
buffer.append( "<B>" + DF.format( dataInicioPanel.getDate() ) + "</B> a <B>"
|
|
+ DF.format( dataFimPanel.getDate() ) + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "</TR>" );
|
|
buffer.append( "</TABLE>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>EMPRESA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>NOME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ÚLTIMO EXAME</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTADO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ÚLTIMA CONSULTA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTADO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getDadosTrabalhadoresPeriodo( inicio, fim );
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 0; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
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( "<P ALIGN=\"center\">" );
|
|
buffer.append( "<B><FONT SIZE=\"+2\">" + ESTATISTICAS[ LISTAGEM_GLOBAL_HIGIENE_SEGURANCA ] + "</FONT></B>" );
|
|
buffer.append( "</P>" );
|
|
buffer.append( "<BR>" );
|
|
|
|
buffer.append( "<TABLE BORDER=\"0\">" );
|
|
buffer.append( "<TR>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>EMPRESA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTABELECIMENTO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ÚLTIMA AUDITORIA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>ESTADO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>RELATÓRIO</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "<TD ALIGN=\"center\">" );
|
|
buffer.append( "<I>PRÓXIMA AUDITORIA</I>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
buffer.append( "</TR>" );
|
|
String data[][] = provider.getDadosHigieneSeguranca();
|
|
for( int l = 0; l < data.length; l++ )
|
|
{
|
|
buffer.append( "<TR>" );
|
|
for( int c = 0; c < data[ l ].length; c++ )
|
|
{
|
|
buffer.append( "<TD ALIGN=\"left\">" );
|
|
buffer.append( "<B>" + data[ l ][ c ] + "</B>" );
|
|
buffer.append( "</TD>" );
|
|
buffer.append( "<TD></TD>" );
|
|
}
|
|
buffer.append( "</TR>" );
|
|
}
|
|
buffer.append( "</TABLE>" );
|
|
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 = "<style type=\"text/css\">\n"
|
|
+ " td{font-family: arial;"
|
|
+ " font-size: 8pt; }\n"
|
|
+ " p{font-family: arial;"
|
|
+ " font-size: 1pt; }\n"
|
|
+ "</style>";
|
|
text = text.replace( "<head>", "<head>\n\t\t<title>" + title + "</title>\n" + style );
|
|
text = text.replace( "<font size=\"+2\">", "<div style=\"font-family : arial; font-size : 12pt\">" );
|
|
text = text.replace( "</font>", "</div>" );
|
|
// System.out.println( text );
|
|
try
|
|
{
|
|
FileWriter writer = new FileWriter( new File( fullName ) );
|
|
writer.write( text );
|
|
writer.close();
|
|
}
|
|
catch( IOException ex )
|
|
{
|
|
DialogException.showException( ex );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |