|
|
|
|
@ -10,9 +10,12 @@ import info.clearthought.layout.TableLayout;
|
|
|
|
|
import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
|
|
|
|
|
|
import java.awt.Component;
|
|
|
|
|
import java.awt.Cursor;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.EventObject;
|
|
|
|
|
@ -20,6 +23,8 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
|
import javax.swing.ButtonGroup;
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
@ -38,7 +43,8 @@ import siprp.database.cayenne.objects.HsRelatorio;
|
|
|
|
|
import siprp.database.cayenne.objects.MarcacoesEstabelecimento;
|
|
|
|
|
import siprp.database.cayenne.objects.MarcacoesTecnicosHst;
|
|
|
|
|
import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel;
|
|
|
|
|
import siprp.medicina.processo.mail.MailSender;
|
|
|
|
|
import siprp.medicina.processo.mail.MailDialog;
|
|
|
|
|
import siprp.planoactuacao.print.PlanoActuacaoPDFCreator;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
|
|
|
|
|
|
|
|
@ -50,6 +56,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png";
|
|
|
|
|
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png";
|
|
|
|
|
private static final String ICON_NAME_SUBMIT = "siprp/higiene/relatorio/submit.png";
|
|
|
|
|
private static final String ICON_NAME_PDF = "siprp/higiene/relatorio/adobe_reader.png";
|
|
|
|
|
|
|
|
|
|
private final JCalendarPanel dataRelatorio = new JCalendarPanel( null );
|
|
|
|
|
|
|
|
|
|
@ -69,6 +76,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
|
|
|
|
|
private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
|
|
|
|
|
private final LeafIconButton buttonSubmit = LeafIconButton.createButton( "Submeter plano de actua" + ccedil + atilde + "o", ICON_NAME_SUBMIT );
|
|
|
|
|
private final LeafIconButton buttonPdfPlano = LeafIconButton.createButton( "Plano de actua" + ccedil + atilde + "o", ICON_NAME_PDF );
|
|
|
|
|
private final LeafIconButton buttonPdfRelatorio = LeafIconButton.createButton( "Relat" + oacute + "rio", ICON_NAME_PDF );
|
|
|
|
|
|
|
|
|
|
private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel();
|
|
|
|
|
|
|
|
|
|
@ -92,6 +101,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
|
|
|
|
|
private void startupComponents()
|
|
|
|
|
{
|
|
|
|
|
buttonPdfRelatorio.setEnabled( false );
|
|
|
|
|
dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) );
|
|
|
|
|
panelEquipamentos.setPreferredSize( new Dimension( 400, 0 ) );
|
|
|
|
|
bg.add( radioInicial );
|
|
|
|
|
@ -135,7 +145,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) );
|
|
|
|
|
|
|
|
|
|
TableLayout layout = new TableLayout( new double[] {
|
|
|
|
|
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
|
|
|
|
|
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
|
|
|
|
|
}, new double[] {
|
|
|
|
|
TableLayout.MINIMUM
|
|
|
|
|
} );
|
|
|
|
|
@ -146,7 +156,9 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
|
|
|
|
|
panel.add( buttonSave, new TableLayoutConstraints( 0, 0 ) );
|
|
|
|
|
panel.add( buttonRevert, new TableLayoutConstraints( 1, 0 ) );
|
|
|
|
|
panel.add( buttonSubmit, new TableLayoutConstraints( 3, 0 ) );
|
|
|
|
|
panel.add( buttonPdfRelatorio, new TableLayoutConstraints( 3, 0 ) );
|
|
|
|
|
panel.add( buttonPdfPlano, new TableLayoutConstraints( 4, 0 ) );
|
|
|
|
|
panel.add( buttonSubmit, new TableLayoutConstraints( 5, 0 ) );
|
|
|
|
|
|
|
|
|
|
add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) );
|
|
|
|
|
add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
|
|
|
|
@ -199,6 +211,14 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
buttonPdfPlano.addActionListener( new ActionListener()
|
|
|
|
|
{
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
|
|
|
{
|
|
|
|
|
pdf();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isValidPlano()
|
|
|
|
|
@ -225,7 +245,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
{
|
|
|
|
|
relatorio.setIsSubmetido( new Date() );
|
|
|
|
|
relatorio.save();
|
|
|
|
|
// sendMail( relatorio );
|
|
|
|
|
sendMail( relatorio );
|
|
|
|
|
refresh();
|
|
|
|
|
setRelatorio( relatorio, false );
|
|
|
|
|
}
|
|
|
|
|
@ -235,62 +255,132 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean confirmDelete( File file )
|
|
|
|
|
{
|
|
|
|
|
boolean result = false;
|
|
|
|
|
result = JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( this, "Ficheiro j" + aacute + " existente, deseja substituir?", "Aviso", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null );
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pdf()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
setCursor( new Cursor(Cursor.WAIT_CURSOR) );
|
|
|
|
|
PlanoActuacaoPDFCreator creator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
byte [] pdf = creator.createPDF( relatorio.getId(), false );
|
|
|
|
|
if( pdf != null )
|
|
|
|
|
{
|
|
|
|
|
JFileChooser fileChooser = new JFileChooser( );
|
|
|
|
|
if( fileChooser.showSaveDialog( this ) == JFileChooser.APPROVE_OPTION )
|
|
|
|
|
{
|
|
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
|
|
String path = file.getAbsolutePath();
|
|
|
|
|
if( !path.toUpperCase().endsWith( ".PDF" ) )
|
|
|
|
|
{
|
|
|
|
|
path += ".pdf";
|
|
|
|
|
file = new File( path );
|
|
|
|
|
}
|
|
|
|
|
if( file != null )
|
|
|
|
|
{
|
|
|
|
|
if( file.exists() && confirmDelete( file ) )
|
|
|
|
|
{
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream a = new FileOutputStream(file);
|
|
|
|
|
a.write( pdf );
|
|
|
|
|
a.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch( Exception e )
|
|
|
|
|
{
|
|
|
|
|
LeafError.error( e );
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
setCursor( new Cursor(Cursor.DEFAULT_CURSOR) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JFrame getFrame( )
|
|
|
|
|
{
|
|
|
|
|
Component comp = this;
|
|
|
|
|
JFrame frame = null;
|
|
|
|
|
while( comp != null )
|
|
|
|
|
{
|
|
|
|
|
if( comp.getParent() instanceof JFrame )
|
|
|
|
|
{
|
|
|
|
|
frame = (JFrame) comp.getParent();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
comp = comp.getParent();
|
|
|
|
|
}
|
|
|
|
|
return frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendMail( HsRelatorio relatorio )
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MailSender sender = new MailSender();
|
|
|
|
|
String nomeEstabelecimento = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNome();
|
|
|
|
|
MarcacoesTecnicosHst tecnico = relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst();
|
|
|
|
|
String nomeTecnico = tecnico == null ? "" : tecnico.getNome();
|
|
|
|
|
Date dataVisita = relatorio.getToHsMarcacoesEstabelecimento().getData();
|
|
|
|
|
String dataVisitaString = new SimpleDateFormat("dd/MM/yyyy").format( dataVisita );
|
|
|
|
|
String subject = "Relatório da Avaliação de Riscos Laborais e Plano de Actuação de " + nomeEstabelecimento + " - auditoria de " + dataVisitaString;
|
|
|
|
|
String body = "<html>Exmos. Senhores" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Junto enviamos o relatório de avaliação de riscos laborais e " +
|
|
|
|
|
"respectivo plano de actuação da auditoria realizada no dia " +
|
|
|
|
|
dataVisitaString +
|
|
|
|
|
"ao vosso estabelecimento de " +
|
|
|
|
|
nomeEstabelecimento +
|
|
|
|
|
". Aconselhamos que tenham em conta as não conformidades indicadas " +
|
|
|
|
|
"nestes documentos e que preencham o plano de actuação por forma a " +
|
|
|
|
|
"auxiliar-vos na planificação das medidas correctivas e para poderem " +
|
|
|
|
|
"apresentá-los em caso de inspecção da ACT – Autoridade para as Condições do Trabalho." +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Caso pretendam o nosso apoio ou necessitem de qualquer esclarecimento, contactem-nos, por favor, através do telefone (+351) 213 504 540." +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Com os melhores cumprimentos, " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
nomeTecnico +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"SIPRP - Sociedade Ibérica de Prevenção de Riscos Profissionais " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Atrium Saldanha - Praça Duque de Saldanha, 1 - 9º G - 1050-094 Lisboa " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Telefone: (+351) 213 504 540 " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Fax: (+351) 213 504 549 " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"E-mail: geral@siprp.pt " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"URL: www.siprp.com " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda</html>";
|
|
|
|
|
|
|
|
|
|
List<HsEmailEstabelecimento> rels = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento();
|
|
|
|
|
String to = "";
|
|
|
|
|
for( HsEmailEstabelecimento rel : rels )
|
|
|
|
|
{
|
|
|
|
|
sender.send( rel.getToHsEmail().getEmail(), "", subject, body, null, null );
|
|
|
|
|
to += rel.getToHsEmail().getEmail() + (to.length() == 0 ? "" : ", ");
|
|
|
|
|
}
|
|
|
|
|
if( to.length() > 0 && to.contains( "@" ) )
|
|
|
|
|
{
|
|
|
|
|
String nomeEstabelecimento = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNome();
|
|
|
|
|
MarcacoesTecnicosHst tecnico = relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst();
|
|
|
|
|
String nomeTecnico = tecnico == null ? "" : tecnico.getNome();
|
|
|
|
|
Date dataVisita = relatorio.getToHsMarcacoesEstabelecimento().getData();
|
|
|
|
|
String dataVisitaString = new SimpleDateFormat("dd/MM/yyyy").format( dataVisita );
|
|
|
|
|
String subject = "Relatório da Avaliação de Riscos Laborais e Plano de Actuação de " + nomeEstabelecimento + " - auditoria de " + dataVisitaString;
|
|
|
|
|
String body = "<html>Exmos. Senhores" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Junto enviamos o relatório de avaliação de riscos laborais e " +
|
|
|
|
|
"respectivo plano de actuação da auditoria realizada no dia " +
|
|
|
|
|
dataVisitaString +
|
|
|
|
|
"ao vosso estabelecimento de(o) " +
|
|
|
|
|
nomeEstabelecimento +
|
|
|
|
|
". Aconselhamos que tenham em conta as não conformidades indicadas " +
|
|
|
|
|
"nestes documentos e que preencham o plano de actuação por forma a " +
|
|
|
|
|
"auxiliar-vos na planificação das medidas correctivas e para poderem " +
|
|
|
|
|
"apresentá-los em caso de inspecção da ACT – Autoridade para as Condições do Trabalho." +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Caso pretendam o nosso apoio ou necessitem de qualquer esclarecimento, contactem-nos, por favor, através do telefone (+351) 213 504 540." +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Com os melhores cumprimentos, " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
nomeTecnico +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"SIPRP - Sociedade Ibérica de Prevenção de Riscos Profissionais " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Atrium Saldanha - Praça Duque de Saldanha, 1 - 9º G - 1050-094 Lisboa " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Telefone: (+351) 213 504 540 " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Fax: (+351) 213 504 549 " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"E-mail: geral@siprp.pt " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"URL: www.siprp.com " +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda.</html>";
|
|
|
|
|
new MailDialog( getFrame(), to, "", subject, body );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
@ -374,6 +464,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
fieldFuncao1.setEnabled( enabled );
|
|
|
|
|
fieldFuncao2.setEnabled( enabled );
|
|
|
|
|
buttonSubmit.setEnabled( enabled );
|
|
|
|
|
buttonPdfPlano.setEnabled( enabled );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRelatorio( HsRelatorio relatorio,boolean create )
|
|
|
|
|
|