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;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.db.keyretrievers.*;
import com.evolute.utils.metadb.*;
@ -24,7 +28,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
private static FichaDataProvider instance = null;
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
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() );
}
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 java.text.*;
import com.evolute.utils.data.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import com.evolute.utils.ui.search.*;
import com.evolute.utils.ui.window.*;
@ -25,6 +27,7 @@ import com.evolute.utils.ui.window.*;
* @author fpalma
*/
public class FichaWindow extends TabbedWindow
implements ListAction
{
private UpperPanel upperPanel;
private EmpresaPanel empresaPanel;
@ -119,6 +122,22 @@ public class FichaWindow extends TabbedWindow
}, "Imprimir",
"Imprimir Ficha", "print",
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(){
public void execute()
@ -363,14 +382,7 @@ public class FichaWindow extends TabbedWindow
System.out.println( "no id" );
return;
}
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( id ) );
byte pdf[] = (byte []) exame.getProperty( fdpProvider.PDF );
if( exame == null )
{
throw new Exception( "N\u00e3o existe exame" );
}
ExamePDF ePDF = new ExamePDF();
ePDF.print( pdf );
print( id );
}
catch( Exception ex )
{
@ -378,6 +390,19 @@ public class FichaWindow extends TabbedWindow
}
}
private void print( Integer exameID )
throws Exception
{
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
byte pdf[] = (byte []) exame.getProperty( fdpProvider.PDF );
if( exame == null )
{
throw new Exception( "N\u00e3o existe exame" );
}
ExamePDF ePDF = new ExamePDF();
ePDF.print( pdf );
}
public byte[] createPDF( MetaObject exame )
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