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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 17 years ago
parent 8a339609ee
commit 0b03933a8b

@ -1,5 +1,7 @@
package siprp.higiene.relatorio;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -7,7 +9,10 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
@ -259,6 +264,11 @@ public class GerirMedidasRelatorioPanel extends JPanel
}
}
private boolean confirm( String message )
{
return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( this, message, "Confirma"+ccedil+atilde+"o", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null );
}
private void rem()
{
try
@ -269,9 +279,37 @@ public class GerirMedidasRelatorioPanel extends JPanel
Object selection = path.getLastPathComponent();
if( selection instanceof MedidaRelatorioNode )
{
HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject();
rel.getToHsRelatorioMedida().delete();
rel.delete();
if( confirm("Tem a certeza que deseja remover o requisito?") )
{
HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject();
rel.getToHsRelatorioMedida().setDeletedDate( new Date() );
rel.delete();
}
}
else if( selection instanceof RiscoRelatorioNode )
{
if( confirm("Tem a certeza que deseja remover o risco?") )
{
HsRelatorioPostoRisco rel = (HsRelatorioPostoRisco) ((RiscoRelatorioNode)selection).getUserObject();
for( HsRelatorioMedida medida : rel.getToHsRelatorioRisco().getHsRelatorioMedidaArray() )
{
while( true )
{
List<HsRelatorioPostoMedida> list = medida.getHsRelatorioPostoMedidaArray();
HsRelatorioPostoMedida relMedida = list.isEmpty() ? null : list.get(0);
if( relMedida != null )
{
relMedida.delete();
}
else
{
break;
}
}
medida.setDeletedDate( new Date() );
}
rel.getToHsRelatorioRisco().setDeletedDate( new Date() );
}
}
}
refresh();
@ -295,7 +333,7 @@ public class GerirMedidasRelatorioPanel extends JPanel
}
}
buttonAdicionar.setEnabled( add && getSelectedRisco() != null );
buttonRemover.setEnabled( rem && getSelectedMedida() != null );
buttonRemover.setEnabled( rem && ( getSelectedMedida() != null || getSelectedRisco() != null ) );
}
public void refresh()
@ -307,14 +345,17 @@ public class GerirMedidasRelatorioPanel extends JPanel
{
RiscoRelatorioNode node = new RiscoRelatorioNode( rel );
HsRelatorioRisco risco = rel.getToHsRelatorioRisco();
for( HsRelatorioMedida medida : risco.getHsRelatorioMedidaArray() )
if( risco.getDeletedDate() == null )
{
for( HsRelatorioPostoMedida medidaRel : medida.getHsRelatorioPostoMedidaArray() )
for( HsRelatorioMedida medida : risco.getHsRelatorioMedidaArray() )
{
node.add( new MedidaRelatorioNode( medidaRel ) );
for( HsRelatorioPostoMedida medidaRel : medida.getHsRelatorioPostoMedidaArray() )
{
node.add( new MedidaRelatorioNode( medidaRel ) );
}
}
root.add( node );
}
root.add( node );
}
}
setEnabled();

@ -240,13 +240,13 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
@Override
public void actionPerformed( ActionEvent e )
{
// if( isValidEmail() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, "Emails n" + atilde + "o preenchidos para este estabelecimento!\nContinuar?", "Aviso", JOptionPane.YES_NO_OPTION ) )
// {
if( isValidEmail() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, "Emails n" + atilde + "o preenchidos para este estabelecimento!\nContinuar?", "Aviso", JOptionPane.YES_NO_OPTION ) )
{
if( isValidPlano() && confirmSubmit() )
{
submit();
}
// }
}
}
} );
buttonPdfPlano.addActionListener( new ActionListener()
@ -356,13 +356,13 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
setCursor(new Cursor(Cursor.WAIT_CURSOR));
if( relatorio != null )
{
// if( sendMail( relatorio ) )
// {
refresh();
relatorio.setIsSubmetido( new Date() );
relatorio.save();
setRelatorio( relatorio, false );
// }
if( sendMail( relatorio ) )
{
refresh();
relatorio.setIsSubmetido( new Date() );
relatorio.save();
setRelatorio( relatorio, false );
}
}
}
catch( Exception e )
@ -461,13 +461,21 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
boolean result = false;
List<HsEmailEstabelecimento> rels = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento();
String to = "";
String bcc = "";
for( HsEmailEstabelecimento rel : rels )
{
to += rel.getToHsEmail().getEmail() + ",";
if( to.isEmpty() )
{
to += rel.getToHsEmail().getEmail();
}
else
{
bcc += rel.getToHsEmail().getEmail() + ", ";
}
}
if(to.endsWith( "," ))
if(bcc.endsWith( ", " ))
{
to = to.substring( 0, to.length() - 1 );
bcc = bcc.substring( 0, bcc.length() - 2 );
}
if( to.length() > 0 )
{
@ -477,7 +485,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
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" +
String body = "<html><p align=\"justify\"><font size=\"3\" face=\"Arial\">Exmos. Senhores" +
"<br>" +
"<br>" +
"<br>" +
@ -517,8 +525,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
"<br>" +
"<br>" +
"<br>" +
"Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda.</html>";
MailDialog md = new MailDialog( getFrame(), to, "", subject, body, getRelatoriosTemp(relatorio) );
"Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda.</font></p></html>";
MailDialog md = new MailDialog( getFrame(), to, bcc, subject, body, getRelatoriosTemp(relatorio) );
result = md.wasSent();
}
return result;

@ -5,6 +5,7 @@ import info.clearthought.layout.TableLayoutConstraints;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.GridLayout;
@ -121,7 +122,7 @@ public class MailDialog extends CustomJDialog
setMessage( message );
attach( files );
setModal( true );
setSize( 1024, 768 );
setSize( 800, 600 );
setLocationRelativeTo( null );
setVisible( true );
}
@ -174,7 +175,15 @@ public class MailDialog extends CustomJDialog
public void actionPerformed( ActionEvent e )
{
send();
try
{
setCursor( new Cursor(Cursor.WAIT_CURSOR) );
send();
}
finally
{
setCursor( new Cursor(Cursor.DEFAULT_CURSOR ) );
}
close();
}
};
@ -235,10 +244,8 @@ public class MailDialog extends CustomJDialog
JLabel toLabel = new JLabel( "Para:" );
toText = new JTextField();
toText.setEditable( false );
JLabel bccLabel = new JLabel( "C\u00f3pia:" );
bccText = new JTextField();
bccText.setEditable( false );
JLabel assuntoLabel = new JLabel( "Assunto:" );
subjectText = new JTextField();
attachmentsModel = new VectorTableModel<String>( new String[]{ "" } );

@ -46,7 +46,7 @@ public class MailSender
msg.setFrom( new InternetAddress( from ) );
msg.setReplyTo( new Address[]{ new InternetAddress(from)} );
msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( to, true ) );
msg.setRecipients( Message.RecipientType.BCC, InternetAddress.parse( bcc, true ) );
msg.setRecipients( Message.RecipientType.CC, InternetAddress.parse( bcc, true ) );
msg.setSubject( subject );
MimeBodyPart bodyPart = new MimeBodyPart();

Loading…
Cancel
Save