|
|
|
|
@ -11,6 +11,8 @@ package siprp.medicina.presencas;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.data.IDObject;
|
|
|
|
|
import com.evolute.utils.data.MappableObject;
|
|
|
|
|
import com.evolute.utils.fop.FOPCreator;
|
|
|
|
|
import com.evolute.utils.fop.FOPPrinter;
|
|
|
|
|
import com.evolute.utils.tracker.TrackableWindow;
|
|
|
|
|
import com.evolute.utils.ui.DialogException;
|
|
|
|
|
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
|
|
|
@ -21,12 +23,21 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
|
|
import java.awt.event.WindowEvent;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import org.jdom.*;
|
|
|
|
|
import org.jdom.output.*;
|
|
|
|
|
import siprp.clientes.ClientesDataProvider;
|
|
|
|
|
import siprp.medicina.MedicinaDataProvider;
|
|
|
|
|
import siprp.medicina.prestadores.PrestadoresDataProvider;
|
|
|
|
|
|
|
|
|
|
@ -37,6 +48,9 @@ import siprp.medicina.prestadores.PrestadoresDataProvider;
|
|
|
|
|
public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
implements ActionListener, TrackableWindow
|
|
|
|
|
{
|
|
|
|
|
protected static final String PRINT_TEMPLATE = "/siprp/medicina/presencas/auxiliares.xsl";
|
|
|
|
|
protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
|
|
|
|
|
|
|
|
|
protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 );
|
|
|
|
|
protected static final Integer PRESTADOR_ID_TODOS = new Integer( -2 );
|
|
|
|
|
|
|
|
|
|
@ -47,6 +61,7 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
protected JButton carregarButton;
|
|
|
|
|
protected JComboBox prestadoresCombo;
|
|
|
|
|
protected JButton recarregarPrestadoresButton;
|
|
|
|
|
protected JButton imprimirAuxiliaresButton;
|
|
|
|
|
protected JScrollPane listECDsScroll;
|
|
|
|
|
protected JScrollPane listConsultasScroll;
|
|
|
|
|
protected MultipleActionListPanel listECDsPanel;
|
|
|
|
|
@ -55,6 +70,8 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
protected MedicinaDataProvider provider;
|
|
|
|
|
protected PrestadoresDataProvider prestadoresProvider;
|
|
|
|
|
|
|
|
|
|
protected Presenca ECDS[];
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of RegistarPresencasWindow */
|
|
|
|
|
public RegistarPresencasWindow()
|
|
|
|
|
throws Exception
|
|
|
|
|
@ -77,6 +94,8 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
prestadoresCombo = new JComboBox ();
|
|
|
|
|
recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" );
|
|
|
|
|
recarregarPrestadoresButton.addActionListener( this );
|
|
|
|
|
imprimirAuxiliaresButton = new JButton( "Imprimir" );
|
|
|
|
|
imprimirAuxiliaresButton.addActionListener( this );
|
|
|
|
|
|
|
|
|
|
PresencasActionFactory realizouFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU );
|
|
|
|
|
PresencasActionFactory realizouParcialmenteFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU_PARCIALMENTE );
|
|
|
|
|
@ -117,6 +136,7 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
upperPanel.add( prestadoresLabel );
|
|
|
|
|
upperPanel.add( prestadoresCombo );
|
|
|
|
|
upperPanel.add( recarregarPrestadoresButton );
|
|
|
|
|
upperPanel.add( imprimirAuxiliaresButton );
|
|
|
|
|
|
|
|
|
|
setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
|
|
|
|
|
addWindowListener( new WindowAdapter(){
|
|
|
|
|
@ -145,6 +165,10 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
{
|
|
|
|
|
recarregarPrestadores();
|
|
|
|
|
}
|
|
|
|
|
else if( source.equals( imprimirAuxiliaresButton ) )
|
|
|
|
|
{
|
|
|
|
|
imprimirAuxiliares();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void refresh()
|
|
|
|
|
@ -175,6 +199,7 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
|
|
|
|
|
protected void carregar()
|
|
|
|
|
{
|
|
|
|
|
ECDS = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Date data = dataPanel.getDate();
|
|
|
|
|
@ -190,7 +215,8 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
ecds.add( new Presenca( id, nome, nomePlain, empresa, tipo ) );
|
|
|
|
|
}
|
|
|
|
|
Collections.sort( ecds );
|
|
|
|
|
listECDsPanel.showList( ecds.toArray( new Presenca[ ecds.size() ] ) );
|
|
|
|
|
ECDS = ecds.toArray( new Presenca[ ecds.size() ] );
|
|
|
|
|
listECDsPanel.showList( ECDS );
|
|
|
|
|
listECDsScroll.setViewportView( listECDsPanel );
|
|
|
|
|
|
|
|
|
|
Object consultasArray[][] = provider.getListaConsultasByData( data );
|
|
|
|
|
@ -233,4 +259,79 @@ public class RegistarPresencasWindow extends JFrame
|
|
|
|
|
DialogException.showExceptionMessage( ex, "Erro a carregar prestadores", true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void imprimirAuxiliares()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Date data = dataPanel.getDate();
|
|
|
|
|
if( ECDS == null || data == null )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ClientesDataProvider clientesProvider =
|
|
|
|
|
( ClientesDataProvider ) ClientesDataProvider.getProvider();
|
|
|
|
|
MedicinaDataProvider medicinaProvider =
|
|
|
|
|
( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
|
|
|
|
|
|
|
|
|
|
String dataStr = D_F.format( data );
|
|
|
|
|
|
|
|
|
|
Element rootElement = new Element( "lista-presencas" );
|
|
|
|
|
|
|
|
|
|
for( int n = 0; n < ECDS.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
Element presencaElement = new Element( "presenca" );
|
|
|
|
|
|
|
|
|
|
Element trabalhadorElement = new Element( "trabalhador" );
|
|
|
|
|
trabalhadorElement.setText( ECDS[ n ].getNome() );
|
|
|
|
|
presencaElement.addContent( trabalhadorElement );
|
|
|
|
|
|
|
|
|
|
Element empresaElement = new Element( "empresa" );
|
|
|
|
|
empresaElement.setText( ECDS[ n ].getNomeEmpresa() );
|
|
|
|
|
presencaElement.addContent( empresaElement );
|
|
|
|
|
|
|
|
|
|
Element dataElement = new Element( "data" );
|
|
|
|
|
dataElement.setText( dataStr );
|
|
|
|
|
presencaElement.addContent( dataElement );
|
|
|
|
|
|
|
|
|
|
Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( ECDS[ n ].getID() );
|
|
|
|
|
Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID );
|
|
|
|
|
Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( ECDS[ n ].getID() );
|
|
|
|
|
Vector realizadosVector = new Vector();
|
|
|
|
|
realizadosVector.addAll( Arrays.asList( realizados ) );
|
|
|
|
|
IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
|
|
|
|
|
for( int v = 0; v < validos.length; v++ )
|
|
|
|
|
{
|
|
|
|
|
Integer id = validos[ v ].getID();
|
|
|
|
|
if( !realizadosVector.contains( id ) )
|
|
|
|
|
{
|
|
|
|
|
Element ecdElement = new Element( "ecd" );
|
|
|
|
|
ecdElement.setText( validos[ v ].toString() );
|
|
|
|
|
presencaElement.addContent( ecdElement );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rootElement.addContent( presencaElement );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Document doc = new Document( rootElement );
|
|
|
|
|
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
|
|
//new XMLOutputter().output( doc, System.out );
|
|
|
|
|
new XMLOutputter().output( doc, baos );
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
FOPCreator creator = FOPCreator.getFOPCreator();
|
|
|
|
|
InputStream xmlIn = new ByteArrayInputStream( baos.toByteArray() );
|
|
|
|
|
creator.createFOfromXML( xmlIn,
|
|
|
|
|
getClass().getResourceAsStream( PRINT_TEMPLATE ),
|
|
|
|
|
out );
|
|
|
|
|
ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
|
|
|
|
|
Hashtable printOptions = new Hashtable();
|
|
|
|
|
FOPPrinter.getFOPPrinter().printFO( in, true, true, printOptions );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
DialogException.showExceptionMessage( ex, "Erro a imprimir", true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|