Search in sources :

Example 11 with PrintInfo

use of org.compiere.model.PrintInfo in project adempiere by adempiere.

the class AReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private void launchReport(MPrintFormat pf) {
    int Record_ID = 0;
    //  The query is passed into AReport.java with only the key or link column included.
    if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer)
        Record_ID = ((Integer) m_query.getCode(0)).intValue();
    //  Add the extended query after the record ID has been identified.
    if (m_whereExtended != null && m_whereExtended.length() > 0 && m_query != null)
        m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, m_whereExtended, false));
    PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
    info.setDescription(m_query.getInfo());
    if (pf != null && pf.getJasperProcess_ID() > 0) {
        // It's a report using the JasperReports engine
        ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
        //	Execute Process
        ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
        re.setWhereExtended(m_whereExtended);
        re.setWindowNo(WindowNo);
        ReportCtl.preview(re);
    }
}
Also used : ProcessCtl(org.compiere.apps.ProcessCtl) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo)

Example 12 with PrintInfo

use of org.compiere.model.PrintInfo in project adempiere by adempiere.

the class VPrintDocument method print.

@Override
public void print(PO document, String printFormantName, int windowNo) {
    JFrame window = Env.getWindow(windowNo);
    if (ADialog.ask(windowNo, window, "PrintShipments")) {
        window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        //	see also ProcessDialog.printShipments/Invoices
        int retValue = ADialogDialog.A_CANCEL;
        do {
            String keyColumnName = document.get_KeyColumns()[0];
            MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID(printFormantName, document.get_Table_ID(), 0), false);
            MQuery query = new MQuery(document.get_TableName());
            query.addRestriction(keyColumnName, MQuery.EQUAL, document.get_ValueAsInt(keyColumnName));
            //	Engine
            PrintInfo info = new PrintInfo(document.get_TableName(), document.get_Table_ID(), document.get_ValueAsInt(keyColumnName));
            ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
            re.print();
            new Viewer(re);
            ADialogDialog d = new ADialogDialog(window, Env.getHeader(Env.getCtx(), windowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
            retValue = d.getReturnCode();
        } while (retValue == ADialogDialog.A_CANCEL);
        window.setCursor(Cursor.getDefaultCursor());
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) JFrame(javax.swing.JFrame) ADialogDialog(org.compiere.apps.ADialogDialog) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Viewer(org.compiere.print.Viewer)

Example 13 with PrintInfo

use of org.compiere.model.PrintInfo in project adempiere by adempiere.

the class WReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private File launchReport(MPrintFormat pf, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
    int Record_ID = 0;
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    //Instance pInstance = new MPInstance (wsc.ctx, 0, 0);
    File fileName = null;
    if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer) {
        Record_ID = ((Integer) m_query.getCode(0)).intValue();
    }
    PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
    info.setDescription(m_query.getInfo());
    if (pf != null && pf.getJasperProcess_ID() > 0) {
        // It's a report using the JasperReports engine
        ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID());
        Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
        //	Execute Process
        WProcessCtl.process(this, m_curTab.getAD_Window_ID(), pi, trx, request);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(wsc.ctx, pf, m_query, info);
        if (re == null) {
            log.info("Could not start ReportEngine");
        } else {
            try {
                File file = File.createTempFile("WProcess", ".pdf");
                boolean ok = re.createPDF(file);
                if (ok) {
                    fileName = file;
                } else {
                    log.info("Could not create Report");
                }
            } catch (Exception e) {
                log.info(e.toString());
            }
        }
    }
    return fileName;
}
Also used : ReportEngine(org.compiere.print.ReportEngine) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo) Trx(org.compiere.util.Trx) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File) ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 14 with PrintInfo

use of org.compiere.model.PrintInfo in project adempiere by adempiere.

the class WReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private void launchReport(MPrintFormat pf) {
    int Record_ID = 0;
    //  The query is passed into A/WReport.java with only the key or link column included.
    if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer)
        Record_ID = ((Integer) m_query.getCode(0)).intValue();
    //  Add the extended query after the record ID has been identified.
    if (m_whereExtended != null && m_whereExtended.length() > 0 && m_query != null)
        m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, m_whereExtended, false));
    PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
    info.setDescription(m_query.getInfo());
    if (pf != null && pf.getJasperProcess_ID() > 0) {
        // It's a report using the JasperReports engine
        ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
        //	Execute Process
        WProcessCtl.process(null, WindowNo, pi, null);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
        // TODO: Is this required?  The extended query, if any, is included in the query.
        re.setWhereExtended(m_whereExtended);
        ReportCtl.preview(re);
    }
}
Also used : ReportEngine(org.compiere.print.ReportEngine) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo)

Example 15 with PrintInfo

use of org.compiere.model.PrintInfo in project adempiere by adempiere.

the class Process method startFinReport.

//	startCheckPrint
/**
	 *	Start Financial Report.
	 *  @param pi Process Info
	 *  @return true if OK
	 */
public static ReportEngine startFinReport(ProcessInfo pi) {
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    //  Create Query from Parameters
    String TableName = pi.getAD_Process_ID() == 202 ? "T_Report" : "T_ReportStatement";
    MQuery query = MQuery.get(Env.getCtx(), pi.getAD_PInstance_ID(), TableName);
    //	Get PrintFormat
    MPrintFormat format = (MPrintFormat) pi.getTransientObject();
    if (format == null)
        format = (MPrintFormat) pi.getSerializableObject();
    if (format == null) {
        log.log(Level.SEVERE, "startFinReport - No PrintFormat");
        return null;
    }
    PrintInfo info = new PrintInfo(pi);
    ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
    //new Viewer(re);
    return re;
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) JasperPrint(net.sf.jasperreports.engine.JasperPrint)

Aggregations

PrintInfo (org.compiere.model.PrintInfo)25 MQuery (org.compiere.model.MQuery)19 ReportEngine (org.compiere.print.ReportEngine)15 MPrintFormat (org.compiere.print.MPrintFormat)13 File (java.io.File)6 SQLException (java.sql.SQLException)5 Language (org.compiere.util.Language)5 IOException (java.io.IOException)4 ProcessInfo (org.compiere.process.ProcessInfo)4 FileInputStream (java.io.FileInputStream)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 ADialogDialog (org.compiere.apps.ADialogDialog)3 MClient (org.compiere.model.MClient)3 MTable (org.compiere.model.MTable)3 Viewer (org.compiere.print.Viewer)3 Properties (java.util.Properties)2 ServletException (javax.servlet.ServletException)2 RowSet (javax.sql.RowSet)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2