no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@82 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
Frederico Palma 22 years ago
parent a61c0426d0
commit f590c69573

@ -6,8 +6,12 @@
package siprp; package siprp;
import java.text.*;
import java.util.*;
import com.evolute.utils.*; import com.evolute.utils.*;
import com.evolute.utils.arrays.*; import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*; import com.evolute.utils.db.*;
import com.evolute.utils.db.keyretrievers.*; import com.evolute.utils.db.keyretrievers.*;
import com.evolute.utils.metadb.*; import com.evolute.utils.metadb.*;
@ -24,7 +28,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
private static FichaDataProvider instance = null; private static FichaDataProvider instance = null;
private final Executer executer; private final Executer executer;
public static final String SIPRP = "Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais"; public static final String SIPRP = "SIPRP - Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais";
// empresas // empresas
public static final String T_EMPRESAS = "empresas"; public static final String T_EMPRESAS = "empresas";
@ -329,4 +333,23 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
} }
return new Integer( ( (Number) array.get( 0, 0 ) ).intValue() ); return new Integer( ( (Number) array.get( 0, 0 ) ).intValue() );
} }
public IDObject []getAllFichasForTrabalhador( Integer trabalhadorID )
throws Exception
{
Select select =
new Select( new String[]{ T_EXAMES }, new String[]{ "MAX("+ID+")", DATA },
new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ),
new String[]{ DATA + " DESC" }, new String[]{ DATA } );
Virtual2DArray array = executer.executeQuery( select );
IDObject exames[] = new IDObject[ array.columnLength() ];
DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
for( int n = 0; n < exames.length; n++ )
{
Date date = (Date)array.get( n, 1 );
Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
exames[ n ] = new MappableObject( id, date != null? df.format( date ): "" );
}
return exames;
}
} }

@ -15,8 +15,10 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import java.text.*; import java.text.*;
import com.evolute.utils.data.*;
import com.evolute.utils.metadb.*; import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.*; import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import com.evolute.utils.ui.search.*; import com.evolute.utils.ui.search.*;
import com.evolute.utils.ui.window.*; import com.evolute.utils.ui.window.*;
@ -25,6 +27,7 @@ import com.evolute.utils.ui.window.*;
* @author fpalma * @author fpalma
*/ */
public class FichaWindow extends TabbedWindow public class FichaWindow extends TabbedWindow
implements ListAction
{ {
private UpperPanel upperPanel; private UpperPanel upperPanel;
private EmpresaPanel empresaPanel; private EmpresaPanel empresaPanel;
@ -120,6 +123,22 @@ public class FichaWindow extends TabbedWindow
"Imprimir Ficha", "print", "Imprimir Ficha", "print",
0, true ); 0, true );
registerAction( new ActionHandler(){
public void execute()
{
printOld();
}
public boolean activate( boolean newAction, boolean editAction,
boolean cancelAction, boolean saveAction,
boolean deleteAction, boolean selectAction )
{
return saveAction || editAction;
}
}, "Imprimir Fichas Anteriores",
"Imprimir Fichas Anteriores", null,
0, false );
registerAction( new ActionHandler(){ registerAction( new ActionHandler(){
public void execute() public void execute()
{ {
@ -363,7 +382,18 @@ public class FichaWindow extends TabbedWindow
System.out.println( "no id" ); System.out.println( "no id" );
return; return;
} }
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( id ) ); print( id );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel imprimir", true );
}
}
private void print( Integer exameID )
throws Exception
{
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
byte pdf[] = (byte []) exame.getProperty( fdpProvider.PDF ); byte pdf[] = (byte []) exame.getProperty( fdpProvider.PDF );
if( exame == null ) if( exame == null )
{ {
@ -372,11 +402,6 @@ public class FichaWindow extends TabbedWindow
ExamePDF ePDF = new ExamePDF(); ExamePDF ePDF = new ExamePDF();
ePDF.print( pdf ); ePDF.print( pdf );
} }
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel imprimir", true );
}
}
public byte[] createPDF( MetaObject exame ) public byte[] createPDF( MetaObject exame )
throws Exception throws Exception
@ -565,4 +590,51 @@ public class FichaWindow extends TabbedWindow
} }
} }
private void printOld()
{
if( trabalhadorID == null )
{
return;
}
Vector linhas;
try
{
IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID );
linhas = new Vector( Arrays.asList( fichas ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true );
return;
}
ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" },
linhas, this );
dialog.setSize( 250, 200 );
dialog.show();
}
public boolean executeListAction( int line, Object value )
{
if( value == null )
{
return true;
}
try
{
print( ( ( IDObject )value ).getID() );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a imprimir Ficha", true );
return false;
}
return true;
}
public String getListActionName()
{
return "Imprimir";
}
} }

Loading…
Cancel
Save