diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java index 36e0e272..900dbe02 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java +++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java @@ -62,30 +62,43 @@ public class FichaAptidaoCreator implements FichaAptidaoConstants fopPrinter.printFO( in, true, false, null ); } - public byte[] createFO( HashMap values ) +// public byte[] createFO( HashMap values ) +// throws Exception +// { +// StringBuilder buff = new StringBuilder( "\n\n" ); +// +// values.put( PORTARIA, "Portaria n. 299/2007, de 16 de Março" ); +// +//// ☐ square +//// ☑ checked square +// +// for( String key: values.keySet() ) +// { +// buff.append( "\t<" + key + ">" ); +// String val = values.get( key ); +// buff.append( UnicodeChecker.parseToUnicode( "&#x", ";", val, true ) ); +// buff.append( "\n" ); +// } +// buff.append( "" ); +// String xml = buff.toString(); +// +// System.out.println( "XML: " + xml ); +// +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() ); +// +// InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" ); +// fopCreator.createFOfromXML( xmlIn, xslStream, out ); +// // System.out.println( "FO created" ); +// +// return out.toByteArray(); +// } + + public byte[] createFO( byte []xml ) throws Exception { - StringBuilder buff = new StringBuilder( "\n\n" ); - - values.put( PORTARIA, "Portaria n. 299/2007, de 16 de Março" ); - -// ☐ square -// ☑ checked square - - for( String key: values.keySet() ) - { - buff.append( "\t<" + key + ">" ); - String val = values.get( key ); - buff.append( UnicodeChecker.parseToUnicode( "&#x", ";", val, true ) ); - buff.append( "\n" ); - } - buff.append( "" ); - String xml = buff.toString(); - - System.out.println( "XML: " + xml ); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() ); + InputStream xmlIn = new ByteArrayInputStream( xml ); InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" ); fopCreator.createFOfromXML( xmlIn, xslStream, out ); diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java index 492e2a09..985f3238 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java @@ -79,6 +79,8 @@ public class FichaWindow extends TabbedWindow private Integer imposedTrabalhadorID = null; private SaveExameListener exameListener = null; + private boolean useFO = false; + /** Creates a new instance of FichaWindow */ private FichaWindow() throws Exception @@ -186,6 +188,22 @@ public class FichaWindow extends TabbedWindow }, "Imprimir Fichas Anteriores", "Imprimir Fichas Anteriores", null, 0, false ); + + registerAction( new ActionHandler(){ + public void execute() + { + printOldFO(); + } + + public boolean activate( boolean newAction, boolean editAction, + boolean cancelAction, boolean saveAction, + boolean deleteAction, boolean selectAction ) + { + return saveAction || editAction; + } + }, "Imprimir Fichas Anteriores (novo)", + "Imprimir Fichas Anteriores (novo)", null, + 0, false ); registerAction( new ActionHandler(){ public void execute() @@ -295,10 +313,21 @@ public class FichaWindow extends TabbedWindow // exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador ); exame.set( ExameData.MEDICO, medico ); exame.set( ExameData.TRABALHADOR, trabalhador ); + + byte fo[] = null; + try + { + fo = createFO( exame ); + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a criar nova vers\u00e3o de ficha", true ); + } + try { // lflores - disable FO for now - byte fo[] = null; //createFO( exame ); + // System.out.println( "FO sz: " + fo.length ); exame.set( ExameData.FO, fo ); @@ -565,15 +594,36 @@ public class FichaWindow extends TabbedWindow ePDF.print( pdf, nomeFicheiro ); } } + + private void printFO( Integer exameID ) + throws Exception + { + // MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); + ExameData exame = (ExameData) JDO.load( ExameData.class, exameID ); + if( exame == null ) + { + throw new Exception( "N\u00e3o existe exame" ); + } + + // lflores - ignore FO (for now) + byte fo[] = (byte []) exame.get( ExameData.FO ); + + if( fo != null ) + { + byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo ); + new PDFFilePrinter( pdf, true ); + } + } public byte[] createFO( ExameData exame ) throws Exception { - HashMap ht = createMapFromExame(exame); + byte xml[] = createXmlFromExame( exame ); +// HashMap ht = createMapFromExame(exame); // ExamePDF ePDF = new ExamePDF(); // return ePDF.createPDF( ht ); - return FichaAptidaoCreator.getCreator().createFO( ht ); + return FichaAptidaoCreator.getCreator().createFO( xml ); } public byte[] createPDF( ExameData exame ) @@ -777,7 +827,7 @@ public class FichaWindow extends TabbedWindow Element rootElement = new Element( "FichaAptidao" ); Element portariaElement = new Element( "portaria" ); - portariaElement.setText( "Portaria n. 299/2007, de 16 de Março" ); + portariaElement.setText( "Portaria n. 299/2007, de 16 de Mar\u00e7o" ); rootElement.addContent( portariaElement ); Element empresaElement = new Element( "empresa" ); @@ -1031,6 +1081,30 @@ public class FichaWindow extends TabbedWindow ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" }, linhas, this ); dialog.setSize( 250, 200 ); + useFO = false; + dialog.setVisible( true ); + } + } + + private void printOldFO() + { + if( trabalhadorID != null ) + { + 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 ); + useFO = true; dialog.setVisible( true ); } } @@ -1041,7 +1115,14 @@ public class FichaWindow extends TabbedWindow { try { - print( ( ( IDObject )value ).getID() ); + if( useFO ) + { + printFO( ( ( IDObject )value ).getID() ); + } + else + { + print( ( ( IDObject )value ).getID() ); + } } catch( Exception ex ) { diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl index 06466de5..948f40ef 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl +++ b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl @@ -12,34 +12,29 @@ + margin-bottom="0.1cm" margin-left="1.5cm" margin-right="0.75cm"> + font-weight="bold" space-after="6pt"> FICHA DE APTIDÃO - Z - + font-weight="bold" space-after="6pt"> ( ) + border-style="solid" border-width="medium" > - + space-before="8pt" margin-left="0.2cm"> DESIGNAÇÃO SOCIAL: @@ -66,7 +61,7 @@ + space-before="8pt" margin-left="0.2cm"> ESTABELECIMENTO: @@ -75,7 +70,7 @@ + space-before="8pt" margin-left="0.2cm"> LOCALIDADE: @@ -85,7 +80,7 @@ - + @@ -223,7 +218,7 @@ - + @@ -379,7 +374,7 @@ + space-before="8pt" margin-left="0.2cm"> NOME: @@ -390,7 +385,7 @@ + space-before="8pt" margin-left="0.2cm"> SEXO: @@ -399,7 +394,7 @@ + space-before="8pt" margin-left="0.2cm"> DATA DE NASCIMENTO: @@ -408,7 +403,7 @@ + space-before="8pt" margin-left="0.2cm"> NACIONALIDADE: @@ -419,20 +414,20 @@ + space-before="8pt" margin-left="0.2cm"> NÚMERO MECANOGRÁFICO/OUTRO: + space-before="8pt" margin-left="0.2cm"> CATEGORIA PROFISSIONAL: + space-before="8pt" margin-left="0.2cm"> FUNCAO PROPOSTA: @@ -441,19 +436,19 @@ + space-before="8pt" margin-left="0.2cm"> DATA DE ADMISSÃO: + space-before="8pt" margin-left="0.2cm"> LOCAL DE TRABALHO: + space-before="8pt" margin-left="0.2cm"> DATA DE ADMISSÃO NA FUNÇÃO: + space-before="8pt" margin-left="0.2cm"> @@ -516,17 +511,17 @@ border-right-color="black" border-right-style="solid" border-right-width="thin" number-columns-spanned="1"> + space-before="8pt" margin-left="0.2cm"> DATA DO EXAME: + space-before="8pt" margin-left="0.2cm"> TIPO + space-before="8pt" margin-left="0.2cm"> ❐ @@ -536,13 +531,13 @@ + space-before="8pt" margin-left="0.2cm"> ❐ @@ -552,13 +547,13 @@ + space-before="8pt" margin-left="0.2cm"> ❐ @@ -568,13 +563,13 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -584,13 +579,13 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -600,13 +595,13 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -616,13 +611,13 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -638,7 +633,7 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -654,7 +649,7 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -671,7 +666,7 @@ + space-before="8pt" margin-left="1.2cm"> ❐ @@ -687,7 +682,7 @@ + space-before="8pt" margin-left="0.2cm"> ESPECIFIQUE: @@ -696,11 +691,11 @@ + space-before="8pt" margin-left="0.2cm"> RESULTADO + space-before="8pt" margin-left="0.2cm"> ❐ @@ -716,7 +711,7 @@ + space-before="8pt" margin-left="0.2cm"> ❐ @@ -732,7 +727,7 @@ + space-before="8pt" margin-left="0.2cm"> ❐ @@ -748,7 +743,7 @@ + space-before="8pt" margin-left="0.2cm"> ❐ @@ -764,40 +759,40 @@ + space-before="8pt" margin-left="0.2cm"> + space-before="8pt" margin-left="0.2cm"> OUTRAS FUNÇÕES QUE PODE DESEMPENHAR + space-before="8pt" margin-left="1.2cm"> 1 + select="exame-medico/resultado/outras-funcoes-1" /> + space-before="8pt" margin-left="1.2cm"> 2 + select="exame-medico/resultado/outras-funcoes-2" /> + space-before="8pt" margin-left="1.2cm"> 3 + select="exame-medico/resultado/outras-funcoes-3" /> + space-before="8pt" margin-left="1.2cm"> 4 + select="exame-medico/resultado/outras-funcoes-4" /> + space-before="8pt" margin-left="0.2cm">   @@ -826,13 +821,13 @@ + space-before="8pt" margin-left="0.2cm"> PRÓXIMO EXAME: + space-before="8pt" margin-left="0.2cm"> @@ -882,7 +877,7 @@ DATA: ___/___/______ + space-before="8pt" margin-left="5.2cm"> O RESPONSÁVEL DOS RECURSOS HUMANOS