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.
		
		
		
		
		
			
		
			
				
					
					
						
							595 lines
						
					
					
						
							18 KiB
						
					
					
				
			
		
		
	
	
							595 lines
						
					
					
						
							18 KiB
						
					
					
				/*
 | 
						|
 * MarcacaoPanel.java
 | 
						|
 *
 | 
						|
 * Created on 14 de Maio de 2004, 15:52
 | 
						|
 */
 | 
						|
 | 
						|
package siprp.clientes;
 | 
						|
 | 
						|
import java.awt.*;
 | 
						|
import java.awt.event.*;
 | 
						|
import javax.swing.*;
 | 
						|
import javax.swing.event.*;
 | 
						|
import java.text.*;
 | 
						|
import java.util.*;
 | 
						|
 | 
						|
import com.evolute.utils.*;
 | 
						|
import com.evolute.utils.dataui.*;
 | 
						|
import com.evolute.utils.ui.*;
 | 
						|
import com.evolute.utils.ui.calendar.*;
 | 
						|
import com.evolute.utils.ui.panel.*;
 | 
						|
 | 
						|
import siprp.*;
 | 
						|
import siprp.data.*;
 | 
						|
 | 
						|
/**
 | 
						|
 *
 | 
						|
 * @author  fpalma
 | 
						|
 */
 | 
						|
public class MarcacaoPanel extends JPanel
 | 
						|
	implements ControllableComponent, ActionListener
 | 
						|
{
 | 
						|
	private final String COLUMN_NAMES_REL[];
 | 
						|
	private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
 | 
						|
	
 | 
						|
	private Marcacao marcacoes[];
 | 
						|
	private ComponentsHashtable components;
 | 
						|
	private int tipo;
 | 
						|
	
 | 
						|
	private final boolean comRelatorio;
 | 
						|
	
 | 
						|
	private Box anteriorPanel;
 | 
						|
	private JPanel correntePanel;
 | 
						|
	
 | 
						|
	private String realizadoLabelText;
 | 
						|
	private String relatorioLabelText;
 | 
						|
	
 | 
						|
	private JLabel dataMarcacaoAnteriorLabel;
 | 
						|
	private JCheckBox realizadaCheckBox;
 | 
						|
	private JCalendarPanel dataRelatorioPanel;
 | 
						|
	private JCalendarPanel dataMarcacaoPanel;
 | 
						|
	private JButton enviarEmailButton;
 | 
						|
	private JLabel dataEnvioMailLabel;
 | 
						|
	private JButton historicoButton;
 | 
						|
	
 | 
						|
	private TrabalhadorData trabalhador;
 | 
						|
	private EstabelecimentoData estabelecimento;
 | 
						|
	
 | 
						|
	private MarcacaoListLoader loader;
 | 
						|
	private Marcacao current;
 | 
						|
	private Marcacao last;
 | 
						|
	
 | 
						|
	private boolean filling = false;
 | 
						|
	
 | 
						|
	/** Creates a new instance of MarcacaoPanel */
 | 
						|
	public MarcacaoPanel( boolean comRelatorio, String realizadoLabelText, String relatorioLabelText, int tipo )
 | 
						|
	{
 | 
						|
		this.comRelatorio = comRelatorio;
 | 
						|
		this.realizadoLabelText = realizadoLabelText;
 | 
						|
		this.relatorioLabelText = relatorioLabelText;
 | 
						|
		this.tipo = tipo;
 | 
						|
		COLUMN_NAMES_REL = new String[ comRelatorio ? 3 : 2 ];
 | 
						|
		COLUMN_NAMES_REL[ 0 ] = "Data";
 | 
						|
		COLUMN_NAMES_REL[ 1 ] = realizadoLabelText;
 | 
						|
		if( comRelatorio )
 | 
						|
		{
 | 
						|
			COLUMN_NAMES_REL[ 2 ] = relatorioLabelText;
 | 
						|
		}
 | 
						|
		loader = new MarcacaoListLoader();
 | 
						|
		setupComponents();
 | 
						|
		setupComponentsHashtable();
 | 
						|
	}
 | 
						|
	
 | 
						|
	private void setupComponents()
 | 
						|
	{
 | 
						|
		anteriorPanel = new Box( BoxLayout.X_AXIS );
 | 
						|
		anteriorPanel.setBorder( BorderFactory.createTitledBorder( 
 | 
						|
									BorderFactory.createEtchedBorder(),
 | 
						|
									"Anterior" ) );
 | 
						|
		correntePanel = new JPanel();
 | 
						|
//		correntePanel.setBorder( BorderFactory.createTitledBorder( 
 | 
						|
//									BorderFactory.createEtchedBorder(),
 | 
						|
//									"Corrente" ) );
 | 
						|
		JPanel dataPanel = new JPanel();
 | 
						|
		Box relatorioBox = new Box( BoxLayout.X_AXIS );
 | 
						|
		
 | 
						|
		dataMarcacaoAnteriorLabel = new JLabel( "-" );
 | 
						|
		dataEnvioMailLabel = new JLabel( "" );
 | 
						|
		realizadaCheckBox = new JCheckBox( realizadoLabelText + "  " );
 | 
						|
		realizadaCheckBox.addChangeListener( new ChangeListener(){
 | 
						|
			public void stateChanged( ChangeEvent e )
 | 
						|
			{
 | 
						|
System.out.println( "stateChanged" );
 | 
						|
				if( last != null && !filling )
 | 
						|
				{
 | 
						|
System.out.println( "stateChanged2" );					
 | 
						|
					last.set( Marcacao.REALIZADA, realizadaCheckBox.isSelected() ? "y": "n" );
 | 
						|
					try
 | 
						|
					{
 | 
						|
						last.save();
 | 
						|
					}
 | 
						|
					catch( Exception ex )
 | 
						|
					{
 | 
						|
						DialogException.showExceptionMessage( ex, "Erro a gravar", true );
 | 
						|
						realizadaCheckBox.setSelected( realizadaCheckBox.isSelected() );
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
		} );
 | 
						|
		JLabel relatorioLabel = new JLabel( relatorioLabelText );
 | 
						|
		dataRelatorioPanel = new JCalendarPanel( null );
 | 
						|
		dataRelatorioPanel.addChangeListener( new ChangeListener(){
 | 
						|
			public void stateChanged(ChangeEvent e)
 | 
						|
			{
 | 
						|
				if( !filling )
 | 
						|
				{
 | 
						|
					marcarRelatorio();
 | 
						|
				}
 | 
						|
			}
 | 
						|
			
 | 
						|
			private void marcarRelatorio()
 | 
						|
			{
 | 
						|
				last.set( Marcacao.DATA_RELATORIO, dataRelatorioPanel.getDate() );
 | 
						|
				try
 | 
						|
				{
 | 
						|
					last.save();
 | 
						|
				}
 | 
						|
				catch( Exception ex )
 | 
						|
				{
 | 
						|
					DialogException.showExceptionMessage( ex, "Erro a gravar", true );
 | 
						|
				}
 | 
						|
			}
 | 
						|
		} );
 | 
						|
		
 | 
						|
		dataMarcacaoPanel = new JCalendarPanel( null );
 | 
						|
		dataMarcacaoPanel.addChangeListener( new ChangeListener(){
 | 
						|
			public void stateChanged(ChangeEvent e)
 | 
						|
			{
 | 
						|
				if( !filling )
 | 
						|
				{
 | 
						|
					marcar();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		} );
 | 
						|
		enviarEmailButton = new JButton( "Enviar Email" );
 | 
						|
		enviarEmailButton.addActionListener( this );
 | 
						|
		historicoButton = new JButton( "H" );
 | 
						|
		historicoButton.addActionListener( this );
 | 
						|
		
 | 
						|
		anteriorPanel.add( dataPanel );
 | 
						|
		if( comRelatorio )
 | 
						|
		{
 | 
						|
			anteriorPanel.add( relatorioBox );
 | 
						|
			anteriorPanel.add( relatorioLabel );
 | 
						|
			anteriorPanel.add( dataRelatorioPanel );
 | 
						|
		}
 | 
						|
		
 | 
						|
		dataPanel.setLayout( new GridLayout( 1, 2 ) );
 | 
						|
		dataPanel.add( dataMarcacaoAnteriorLabel );
 | 
						|
		dataPanel.add( realizadaCheckBox );
 | 
						|
		
 | 
						|
		correntePanel.setLayout( new GridLayout( 1, 2 ) );
 | 
						|
		correntePanel.add( dataMarcacaoPanel );
 | 
						|
		correntePanel.add( enviarEmailButton );
 | 
						|
		
 | 
						|
		//setLayout( new BoxLayout( this, BoxLayout.Y_AXIS ) );
 | 
						|
		GridBagLayout gridbag = new GridBagLayout();
 | 
						|
		setLayout( gridbag );
 | 
						|
		GridBagConstraints constraints = new GridBagConstraints();
 | 
						|
		constraints.insets = new Insets( 1, 1, 1, 1 );
 | 
						|
		constraints.fill = GridBagConstraints.HORIZONTAL;
 | 
						|
		constraints.weighty = 0.5;
 | 
						|
		constraints.gridheight = 1;
 | 
						|
		constraints.weightx = 1;
 | 
						|
		constraints.gridwidth = 1;
 | 
						|
		
 | 
						|
		gridbag.setConstraints( anteriorPanel, constraints );
 | 
						|
		add( anteriorPanel );
 | 
						|
		
 | 
						|
		constraints.fill = GridBagConstraints.BOTH;
 | 
						|
		constraints.weighty = 1;
 | 
						|
		constraints.gridheight = 2;
 | 
						|
		constraints.weightx = 0;
 | 
						|
		constraints.gridwidth = GridBagConstraints.REMAINDER;
 | 
						|
		historicoButton.setPreferredSize( new Dimension( 20, 40 ) );
 | 
						|
		gridbag.setConstraints( historicoButton, constraints );
 | 
						|
		add( historicoButton );
 | 
						|
		
 | 
						|
		constraints.fill = GridBagConstraints.HORIZONTAL;
 | 
						|
		constraints.weighty = 0.5;
 | 
						|
		constraints.gridheight = 1;
 | 
						|
		constraints.weightx = 1;
 | 
						|
		constraints.gridwidth = 1;
 | 
						|
		constraints.gridx = 0;
 | 
						|
		gridbag.setConstraints( correntePanel, constraints );
 | 
						|
		add( correntePanel );
 | 
						|
	}
 | 
						|
	
 | 
						|
	private void setupComponentsHashtable()
 | 
						|
	{
 | 
						|
		components = new ComponentsHashtable();
 | 
						|
		components.putComponent( Marcacao.DATA, dataMarcacaoPanel );
 | 
						|
		components.putComponent( Marcacao.REALIZADA, realizadaCheckBox );
 | 
						|
		components.putComponent( Marcacao.DATA_RELATORIO, dataRelatorioPanel );
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void clear()
 | 
						|
	{
 | 
						|
		String names[] = (String[])components.keySet().toArray( new String[0] );
 | 
						|
		ComponentController.clear( names, components );
 | 
						|
		dataMarcacaoAnteriorLabel.setText( "" );
 | 
						|
		dataEnvioMailLabel.setText( "" );
 | 
						|
		marcacoes = null;
 | 
						|
		trabalhador = null;
 | 
						|
		estabelecimento = null;
 | 
						|
		current = null;
 | 
						|
		last = null;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void fill( Object value )
 | 
						|
	{
 | 
						|
		filling = true;
 | 
						|
		clear();
 | 
						|
		if( value == null )
 | 
						|
		{
 | 
						|
			setEnabled( false );
 | 
						|
			filling = false;
 | 
						|
			return;
 | 
						|
		}
 | 
						|
		switch( tipo )
 | 
						|
		{
 | 
						|
			case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
 | 
						|
				if( ! ( value instanceof TrabalhadorData ) )
 | 
						|
				{
 | 
						|
					filling = false;
 | 
						|
					return ;
 | 
						|
				}
 | 
						|
				trabalhador = (TrabalhadorData) value;
 | 
						|
				try
 | 
						|
				{
 | 
						|
					marcacoes = loader.load( tipo, (Integer)trabalhador.get( TrabalhadorData.ID ) );
 | 
						|
				}
 | 
						|
				catch( Exception ex )
 | 
						|
				{
 | 
						|
					DialogException.showExceptionMessage( ex, "Erro a carregar as marca\u00e7\u00f5es", true );
 | 
						|
					marcacoes = null;
 | 
						|
				}
 | 
						|
				break;
 | 
						|
				
 | 
						|
			case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
 | 
						|
				if( ! ( value instanceof EstabelecimentoData ) )
 | 
						|
				{
 | 
						|
					filling = false;
 | 
						|
					return ;
 | 
						|
				}
 | 
						|
				estabelecimento = (EstabelecimentoData) value;
 | 
						|
				try
 | 
						|
				{
 | 
						|
					marcacoes = loader.load( tipo, (Integer)estabelecimento.get( EstabelecimentoData.ID ) );
 | 
						|
				}
 | 
						|
				catch( Exception ex )
 | 
						|
				{
 | 
						|
					DialogException.showExceptionMessage( ex, "Erro a carregar as marca\u00e7\u00f5es", true );
 | 
						|
					marcacoes = null;
 | 
						|
				}
 | 
						|
				break;
 | 
						|
		}
 | 
						|
		if( marcacoes == null || marcacoes.length == 0 )
 | 
						|
		{
 | 
						|
			filling = false;
 | 
						|
			return;
 | 
						|
		}
 | 
						|
		Date lastDate = (Date) marcacoes[ 0 ].get( Marcacao.DATA );
 | 
						|
		current = null;
 | 
						|
		last = null;
 | 
						|
		if( !lastDate.after( new Date() ) )
 | 
						|
		{
 | 
						|
			current = null;
 | 
						|
			last = marcacoes[ 0 ];
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			current = marcacoes[ 0 ];
 | 
						|
			if( marcacoes.length > 1 )
 | 
						|
			{
 | 
						|
				last = marcacoes[ 1 ];
 | 
						|
			}
 | 
						|
		}
 | 
						|
		fillCurrent();
 | 
						|
		fillLast();
 | 
						|
		filling = false;
 | 
						|
	}
 | 
						|
	
 | 
						|
	private void fillCurrent()
 | 
						|
	{
 | 
						|
		if( current != null )
 | 
						|
		{
 | 
						|
			Date dataMarcacao = (Date) current.get( Marcacao.DATA );
 | 
						|
			dataMarcacaoPanel.setDate( dataMarcacao );
 | 
						|
			Date dataMail = (Date) current.get( Marcacao.DATA_EMAIL );
 | 
						|
			if( dataMail == null )
 | 
						|
			{
 | 
						|
				enviarEmailButton.setEnabled( dataMarcacao != null );
 | 
						|
				dataEnvioMailLabel.setText( "" );
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				enviarEmailButton.setEnabled( false );
 | 
						|
				dataEnvioMailLabel.setText( DATE_FORMAT.format( dataMail ) );
 | 
						|
			}
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			enviarEmailButton.setEnabled( false );
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	private void fillLast()
 | 
						|
	{
 | 
						|
		if( last != null )
 | 
						|
		{
 | 
						|
			Date dataMarcacao = (Date) last.get( Marcacao.DATA );
 | 
						|
			dataMarcacaoAnteriorLabel.setText( DATE_FORMAT.format( dataMarcacao ) );
 | 
						|
			String realizada = (String) last.get( Marcacao.REALIZADA );
 | 
						|
			boolean isRealizada = "y".equals( realizada );
 | 
						|
			realizadaCheckBox.setSelected( isRealizada );
 | 
						|
			realizadaCheckBox.setEnabled( !isRealizada );
 | 
						|
			Date dataRelatorio = (Date) last.get( Marcacao.DATA_RELATORIO );
 | 
						|
			dataRelatorioPanel.setDate( dataRelatorio );
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			realizadaCheckBox.setEnabled( false );
 | 
						|
			dataRelatorioPanel.setEnabled( false );
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	public Object save()
 | 
						|
	{
 | 
						|
//		if( marcacoes == null )
 | 
						|
//		{
 | 
						|
//			marcacoes = new Marcacao[ 0 ];
 | 
						|
//		}
 | 
						|
//		if( marcacoes[ marcacoes.length - 1 ] == null )
 | 
						|
//		{
 | 
						|
//			marcacoes[ marcacoes.length - 1 ] = Marcacao.getMarcacao( tipo );
 | 
						|
//		}
 | 
						|
//		if( marcacoes.length > 1 )
 | 
						|
//		{
 | 
						|
//		}
 | 
						|
		return null;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void setEnabled( boolean enable )
 | 
						|
	{
 | 
						|
		filling = true;
 | 
						|
		String names[] = (String[])components.keySet().toArray( new String[0] );
 | 
						|
		ComponentController.setEnabled( names, enable, components );
 | 
						|
		if( !enable )
 | 
						|
		{
 | 
						|
			enviarEmailButton.setEnabled( false );
 | 
						|
		}
 | 
						|
		if( last == null )
 | 
						|
		{
 | 
						|
			realizadaCheckBox.setEnabled( false );
 | 
						|
			dataRelatorioPanel.setEnabled( false );
 | 
						|
		}
 | 
						|
		filling = false;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void actionPerformed( ActionEvent e )
 | 
						|
	{
 | 
						|
		Object source = e.getSource();
 | 
						|
		if( source.equals( enviarEmailButton ) )
 | 
						|
		{
 | 
						|
			Date today = new Date();
 | 
						|
			current.set( Marcacao.DATA_EMAIL, today );
 | 
						|
			String subject = ".";
 | 
						|
			String texto = "";
 | 
						|
			EstabelecimentoData estab = null;
 | 
						|
			if( current instanceof MarcacaoTrabalhadorData )
 | 
						|
			{
 | 
						|
				TrabalhadorData trab = ( TrabalhadorData )current.get( MarcacaoTrabalhadorData.TRABALHADOR );
 | 
						|
				String nome = ( String )trab.get( TrabalhadorData.NOME );
 | 
						|
				String data = DateFormat.getDateInstance( DateFormat.SHORT ).format( ( Date )current.get( MarcacaoTrabalhadorData.DATA ) );
 | 
						|
				if( ( ( Number )current.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() == MarcacaoTrabalhadorConstants.TIPO_EXAMES )
 | 
						|
				{
 | 
						|
					subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_EXAMES );
 | 
						|
					subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
 | 
						|
					texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_EXAMES );
 | 
						|
					texto = texto.replaceAll( CompanyDataLoader.DATA, data );
 | 
						|
					texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
 | 
						|
//					subject = "Marca\u00E7\u00E3o de exame";
 | 
						|
//					texto = "Vimos pelo presente informar que '" + nome + "' dever\u00E1 comparecer "
 | 
						|
//						+ "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o dos exames de Medicina "
 | 
						|
//						+ "do Trabalho, no dia '" + data + "', pelas 08H30."
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "Relembramos que o colaborador dever\u00E1 comparecer em jejum."
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
 | 
						|
//						+ "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
 | 
						|
////						+ "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 210 21 21 "
 | 
						|
//						+ "ou respondendo ao remetente desta mensagem."
 | 
						|
//						+ "%0A%0A%0A"
 | 
						|
//						+ "Cumprimentos,%0A%0ASIPRP";
 | 
						|
////						+ "Cumprimentos,";
 | 
						|
				}
 | 
						|
				else
 | 
						|
				{
 | 
						|
					subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_CONSULTA );
 | 
						|
					subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
 | 
						|
					texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_CONSULTA );
 | 
						|
					texto = texto.replaceAll( CompanyDataLoader.DATA, data );
 | 
						|
					texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
 | 
						|
//					subject = "Marca\u00E7\u00E3o de consulta";
 | 
						|
//					texto = "Vimos pelo presente informar que '" + nome + "' dever\u00E1 comparecer "
 | 
						|
//						+ "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o da consulta de Medicina "
 | 
						|
//						+ "do Trabalho, no dia '" + data + "', pelas 08H30."
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "Solicitamos, tamb\u00E9m, que o colaborador seja portador do Boletim de Vacinas e "
 | 
						|
//						+ "dos \u00FAltimos exames complementares realizados."
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "%0A%0A"
 | 
						|
//						+ "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
 | 
						|
//						+ "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
 | 
						|
////						+ "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 210 21 21 "
 | 
						|
//						+ "ou respondendo ao remetente desta mensagem."
 | 
						|
//						+ "%0A%0A%0A"
 | 
						|
//						+ "Cumprimentos,"
 | 
						|
//						+ "%0A%0ASIPRP"
 | 
						|
//						+ "%0A%0AATRIUM SALDANHA"
 | 
						|
//						+ "%0A%0APra\u00e7a Duque de Saldanha, 1 - 9\u00BAC"
 | 
						|
//						+ "%0A%0A1050-094 Lisboa";
 | 
						|
				}
 | 
						|
				estab = ( EstabelecimentoData )trab.get( TrabalhadorData.ESTABELECIMENTO );
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				estab = ( EstabelecimentoData )current.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
 | 
						|
				String sede = ( String )estab.get( EstabelecimentoData.NOME );
 | 
						|
				subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA );
 | 
						|
				subject = subject.replaceAll( CompanyDataLoader.NOME, sede );
 | 
						|
				String morada = ( String )estab.get( EstabelecimentoData.MORADA );
 | 
						|
				String data = DateFormat.getDateInstance( DateFormat.SHORT ).format( ( Date )current.get( MarcacaoEstabelecimentoData.DATA ) );
 | 
						|
				texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_VISITA );
 | 
						|
				texto = texto.replaceAll( CompanyDataLoader.DATA, data );
 | 
						|
				texto = texto.replaceAll( CompanyDataLoader.NOME, sede );
 | 
						|
				texto = texto.replaceAll( CompanyDataLoader.MORADA, morada );
 | 
						|
//				texto = "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e "
 | 
						|
//					+ "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + sede + "', no dia '" + data + "'."
 | 
						|
//					+ "%0A%0A"
 | 
						|
//					+ "Agradecemos que nos confirme, pela mesma via, o nome do representante "
 | 
						|
//					+ "da empresa que nos ir\u00E1 acompanhar e a vossa disponibilidade para a "
 | 
						|
//					+ "realiza\u00E7\u00E3o da visita na data indicada."
 | 
						|
//					+ "%0A%0A"
 | 
						|
//					+ "Caso necessite de qualquer esclarecimento, contacte-nos, por favor, "
 | 
						|
//					+ "atrav\u00E9s dos telefones 21 350 45 43 (Pedro Vieira), 21 350 45 44 "
 | 
						|
//					+ "(Catarina Leonardo) ou responda ao remetente desta mensagem."
 | 
						|
////					+ "atrav\u00E9s dos telefones 21 210 21 21 (Colaborador), 21 210 21 21 "
 | 
						|
////					+ "(Outro Colaborador) ou responda ao remetente desta mensagem."
 | 
						|
//					+ "%0A%0A%0A"
 | 
						|
//					+ "Cumprimentos,%0A%0ASIPRP";
 | 
						|
////					+ "Cumprimentos,";
 | 
						|
 | 
						|
  
 | 
						|
			}
 | 
						|
			ContactoData cont = ( ContactoData )estab.get( EstabelecimentoData.CONTACTO );
 | 
						|
			String mail = "";
 | 
						|
			if( cont != null )
 | 
						|
			{
 | 
						|
				mail = ( String )cont.get( ContactoData.EMAIL );
 | 
						|
			}
 | 
						|
			try
 | 
						|
			{
 | 
						|
				current.save();
 | 
						|
				if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
 | 
						|
				{
 | 
						|
					mail = mail.replaceAll( " ", "%20" );
 | 
						|
					subject = subject.replaceAll( " ", "%20" );
 | 
						|
					texto = texto.replaceAll( " ", "%20" );
 | 
						|
					Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail 
 | 
						|
						+ "?subject=" + subject + "&body="
 | 
						|
//						+ "?subject=" + subject + "&body="
 | 
						|
						+ texto
 | 
						|
						 );
 | 
						|
				}
 | 
						|
				else
 | 
						|
				{
 | 
						|
					mail = mail.replaceAll( " ", "%20" );
 | 
						|
					subject = subject.replaceAll( " ", "%20" );
 | 
						|
					texto = texto.replaceAll( " ", "%20" );
 | 
						|
//	System.out.println( "mailto:" + mail 
 | 
						|
//	//					+ "?subject=SIPRP - " + subject + "&body="
 | 
						|
//						+ "?subject=" + subject + "&body="
 | 
						|
//						+ texto );
 | 
						|
					Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail 
 | 
						|
	//					+ "?subject=SIPRP - " + subject + "&body="
 | 
						|
						+ "?subject=" + subject + "&body="
 | 
						|
						+ texto } );
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch( Exception ex )
 | 
						|
			{
 | 
						|
				DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
 | 
						|
			}
 | 
						|
			dataEnvioMailLabel.setText( DATE_FORMAT.format( today ) );
 | 
						|
		}
 | 
						|
		else if( source.equals( historicoButton ) )
 | 
						|
		{
 | 
						|
			Vector v = new Vector();
 | 
						|
			if( marcacoes != null )
 | 
						|
			{
 | 
						|
				v.addAll( Arrays.asList( marcacoes ) );
 | 
						|
			}
 | 
						|
			ListActionDialog dialog = 
 | 
						|
				new ListActionDialog( null, "Anteriores", 
 | 
						|
						COLUMN_NAMES_REL, 
 | 
						|
						v, null );
 | 
						|
			dialog.show();
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void marcar()
 | 
						|
	{
 | 
						|
System.out.println( "MARCAR" );
 | 
						|
		Date data = dataMarcacaoPanel.getDate();
 | 
						|
		Vector aux = new Vector();
 | 
						|
		if( marcacoes != null )
 | 
						|
		{
 | 
						|
			aux.addAll( Arrays.asList( marcacoes ) );
 | 
						|
		}
 | 
						|
		if( current == null && data != null )
 | 
						|
		{
 | 
						|
			current = Marcacao.getMarcacao( tipo );
 | 
						|
			current.set( Marcacao.REALIZADA, "n" );
 | 
						|
			
 | 
						|
			aux.insertElementAt( current, 0 );
 | 
						|
			switch( tipo )
 | 
						|
			{
 | 
						|
				case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
 | 
						|
					current.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
 | 
						|
					current.set( MarcacaoTrabalhadorData.TIPO, new Integer( tipo ) );
 | 
						|
					break;
 | 
						|
				
 | 
						|
				case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
 | 
						|
					current.set( MarcacaoEstabelecimentoData.ESTABELECIMENTO, estabelecimento );
 | 
						|
					break;
 | 
						|
			}
 | 
						|
			marcacoes = ( Marcacao [])aux.toArray( new Marcacao[0] );
 | 
						|
//	System.out.println( "INSERI ! !! ! ! !! ! " );
 | 
						|
		}
 | 
						|
		else if( current != null && data == null )
 | 
						|
		{
 | 
						|
			aux.remove( 0 );
 | 
						|
			marcacoes = ( Marcacao [])aux.toArray( new Marcacao[0] );
 | 
						|
//	System.out.println( "REMOVI ! !! ! ! !! ! " );
 | 
						|
		}
 | 
						|
		current.set( Marcacao.DATA, data );
 | 
						|
		
 | 
						|
		try
 | 
						|
		{
 | 
						|
			if( data != null )
 | 
						|
			{
 | 
						|
				current.save();
 | 
						|
				enviarEmailButton.setEnabled( true );
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
	System.out.println( "DELETE DA MARCACAO" );
 | 
						|
				current.delete();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		catch( Exception ex )
 | 
						|
		{
 | 
						|
			DialogException.showExceptionMessage( ex, "Erro a gravar", true );
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void setCalendarDialogOrientation( int vertical, int horizontal )
 | 
						|
	{
 | 
						|
		dataRelatorioPanel.setOrientation( vertical, horizontal );
 | 
						|
		dataMarcacaoPanel.setOrientation( vertical, horizontal );
 | 
						|
	}
 | 
						|
}
 |