|
|
|
|
@ -10,16 +10,13 @@ import com.sun.data.provider.RowKey;
|
|
|
|
|
import com.sun.rave.web.ui.appbase.AbstractPageBean;
|
|
|
|
|
import com.sun.webui.jsf.component.Table;
|
|
|
|
|
import com.sun.webui.jsf.component.TableRowGroup;
|
|
|
|
|
import db.entidades.Area;
|
|
|
|
|
import db.entidades.Medida;
|
|
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
|
|
import db.entidades.PostoTrabalho;
|
|
|
|
|
import db.entidades.Risco;
|
|
|
|
|
import db.providers.UtilizadoresDataProvider;
|
|
|
|
|
import db.entidades.Utilizador;
|
|
|
|
|
import db.entidades.Valor;
|
|
|
|
|
import db.providers.PlanosDataProvider;
|
|
|
|
|
import global.Global;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
@ -27,7 +24,10 @@ import java.util.List;
|
|
|
|
|
import javax.faces.FacesException;
|
|
|
|
|
import javax.faces.component.html.HtmlPanelGrid;
|
|
|
|
|
import javax.faces.context.FacesContext;
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import siprp.database.cayenne.providers.PlanoActuacaoDAO;
|
|
|
|
|
import siprp.planoactuacao.print.PlanoActuacaoPDFCreator;
|
|
|
|
|
import tabledataproviders.PlanosActualDataProvider;
|
|
|
|
|
import tabledataproviders.PlanosConcluidosDataProvider;
|
|
|
|
|
import tabledataproviders.PlanosSeguimentoDataProvider;
|
|
|
|
|
@ -283,9 +283,96 @@ public class ListaPlanos extends AbstractPageBean {
|
|
|
|
|
public String goImprimirPlano_action() {
|
|
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
|
|
// case name where null will return to the same page.
|
|
|
|
|
PlanoActuacao p = getTableActivosRowData();
|
|
|
|
|
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
byte[] pdf = pdfCreator.createPDF(p.getId());
|
|
|
|
|
showPdf(pdf);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String goImprimirPlanoFromSeguimento_action() {
|
|
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
|
|
// case name where null will return to the same page.
|
|
|
|
|
PlanoActuacao p = getTableSeguimentoRowData();
|
|
|
|
|
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
byte[] pdf = pdfCreator.createPDF(p.getId());
|
|
|
|
|
showPdf(pdf);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String goImprimirPlanoFromConcluidos_action() {
|
|
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
|
|
// case name where null will return to the same page.
|
|
|
|
|
PlanoActuacao p = getTableConcluidosRowData();
|
|
|
|
|
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
byte[] pdf = pdfCreator.createPDF(p.getId());
|
|
|
|
|
showPdf(pdf);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showPdf(byte[] pdf) throws Exception
|
|
|
|
|
{
|
|
|
|
|
// FacesContext fc = getFacesContext();
|
|
|
|
|
// HttpServletResponse response = (HttpServletResponse) fc.getExternalContext().getResponse();
|
|
|
|
|
// response.setContentType("application/pdf");
|
|
|
|
|
// //response.getOutputStream().flush();
|
|
|
|
|
// response.flushBuffer();
|
|
|
|
|
// response.getOutputStream().write(pdf, 0, pdf.length);
|
|
|
|
|
// fc.getResponseComplete();
|
|
|
|
|
|
|
|
|
|
System.out.println("PDF LEN : " + pdf.length);
|
|
|
|
|
|
|
|
|
|
FacesContext context = FacesContext.getCurrentInstance();
|
|
|
|
|
HttpServletResponse response =
|
|
|
|
|
(HttpServletResponse)context.getExternalContext().getResponse();
|
|
|
|
|
|
|
|
|
|
response.setHeader("Expires", "0");
|
|
|
|
|
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
|
|
|
|
|
//response.setHeader("Content-disposition","inline; filename=kiran.pdf");
|
|
|
|
|
response.setHeader("Pragma", "public");
|
|
|
|
|
response.setContentType( "application/pdf" );
|
|
|
|
|
//response.setHeader("Content-Disposition", "attachment;filename=\"ContactList.pdf\"");
|
|
|
|
|
response.addHeader("Content-disposition", "attachment;filename=\"Plano.pdf\"");
|
|
|
|
|
|
|
|
|
|
//response.setHeader("Content-disposition", "filename=plano.pdf");
|
|
|
|
|
response.setContentLength(pdf.length);
|
|
|
|
|
//try {
|
|
|
|
|
response.getOutputStream().write(pdf);
|
|
|
|
|
response.getOutputStream().flush();
|
|
|
|
|
response.getOutputStream().close();
|
|
|
|
|
context.responseComplete();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
System.out.println("SHOW PDF");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initialize()
|
|
|
|
|
{
|
|
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
|
|
|