Search in sources :

Example 11 with MPrintFormat

use of org.compiere.print.MPrintFormat in project adempiere by adempiere.

the class WReport method copyFormat.

//	createNewFormat
/**
	 * 	Copy existing Format
	 * 	@param AD_PrintFormat_ID print format
	 * 	@param To_Client_ID to client
	 */
private void copyFormat(int AD_PrintFormat_ID, int To_Client_ID) {
    MPrintFormat pf = MPrintFormat.copyToClient(Env.getCtx(), AD_PrintFormat_ID, To_Client_ID);
    launchReport(pf);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat)

Example 12 with MPrintFormat

use of org.compiere.print.MPrintFormat in project adempiere by adempiere.

the class WReport method launchReport.

//	copyFormatFromClient
/**
	 * 	Launch Report
	 * 	@param pp Key=AD_PrintFormat_ID
	 */
private void launchReport(KeyNamePair pp) {
    MPrintFormat pf = MPrintFormat.get(Env.getCtx(), pp.getKey(), false);
    launchReport(pf);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat)

Example 13 with MPrintFormat

use of org.compiere.print.MPrintFormat in project adempiere by adempiere.

the class CompletePrintOrder method getReportEngine.

// doIt
/*
	 * get the a Report Engine Instance using the view table 
	 * @param tableName
	 */
private ReportEngine getReportEngine(String formatName, String tableName) {
    // Get Format & Data
    int format_id = MPrintFormat.getPrintFormat_ID(formatName, MTable.getTable_ID(tableName), getAD_Client_ID());
    MPrintFormat format = MPrintFormat.get(getCtx(), format_id, true);
    if (format == null) {
        addLog("@NotFound@ @AD_PrintFormat_ID@");
        return null;
    }
    // query
    MQuery query = new MQuery(tableName);
    query.addRestriction("PP_Order_ID", MQuery.EQUAL, p_PP_Order_ID);
    // Engine
    PrintInfo info = new PrintInfo(tableName, MTable.getTable_ID(tableName), p_PP_Order_ID);
    ReportEngine re = new ReportEngine(getCtx(), format, query, info);
    return re;
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo)

Example 14 with MPrintFormat

use of org.compiere.print.MPrintFormat in project adempiere by adempiere.

the class WReport method copyFormat.

//	createNewFormat
/**
	 * 	Copy existing Format
	 * 	@param AD_PrintFormat_ID print format
	 * 	@param To_Client_ID to client
	 */
private File copyFormat(int AD_PrintFormat_ID, int To_Client_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
    WebSessionCtx wsc = WebSessionCtx.get(request);
    MPrintFormat pf = MPrintFormat.copyToClient(wsc.ctx, AD_PrintFormat_ID, To_Client_ID);
    File file = launchReport(pf, request, m_curTab, m_query);
    return file;
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Example 15 with MPrintFormat

use of org.compiere.print.MPrintFormat in project adempiere by adempiere.

the class WGenForm method onPrint.

public void onPrint() {
    //		Loop through all items
    List<File> pdfList = new ArrayList<File>();
    for (int i = 0; i < m_ids.length; i++) {
        int RecordID = m_ids[i];
        ReportEngine re = null;
        if (genForm.getPrintFormat() != null) {
            MPrintFormat format = genForm.getPrintFormat();
            MTable table = MTable.get(Env.getCtx(), format.getAD_Table_ID());
            MQuery query = new MQuery(table.getTableName());
            query.addRestriction(table.getTableName() + "_ID", MQuery.EQUAL, RecordID);
            //	Engine
            PrintInfo info = new PrintInfo(table.getTableName(), table.get_Table_ID(), RecordID);
            re = new ReportEngine(Env.getCtx(), format, query, info);
        } else {
            re = ReportEngine.get(Env.getCtx(), genForm.getReportEngineType(), RecordID);
        }
        if (re != null)
            pdfList.add(re.getPDF());
    }
    if (pdfList.size() > 1) {
        try {
            File outFile = File.createTempFile(genForm.getClass().getName(), ".pdf");
            AEnv.mergePdf(pdfList, outFile);
            Clients.clearBusy();
            Window win = new SimplePDFViewer(getFormName(), new FileInputStream(outFile));
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    } else if (pdfList.size() > 0) {
        Clients.clearBusy();
        try {
            Window win = new SimplePDFViewer(getFormName(), new FileInputStream(pdfList.get(0)));
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
}
Also used : Window(org.adempiere.webui.component.Window) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) ArrayList(java.util.ArrayList) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) FileInputStream(java.io.FileInputStream) ReportEngine(org.compiere.print.ReportEngine) MPrintFormat(org.compiere.print.MPrintFormat) MTable(org.compiere.model.MTable) File(java.io.File)

Aggregations

MPrintFormat (org.compiere.print.MPrintFormat)34 MQuery (org.compiere.model.MQuery)14 PrintInfo (org.compiere.model.PrintInfo)13 ReportEngine (org.compiere.print.ReportEngine)13 File (java.io.File)11 WebSessionCtx (org.compiere.util.WebSessionCtx)6 Language (org.compiere.util.Language)4 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 JasperPrint (net.sf.jasperreports.engine.JasperPrint)3 MTable (org.compiere.model.MTable)3 MPrintFormatItem (org.compiere.print.MPrintFormatItem)3 AdempiereUserError (org.compiere.util.AdempiereUserError)3 Locale (java.util.Locale)2 RowSet (javax.sql.RowSet)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 SimplePDFViewer (org.adempiere.webui.window.SimplePDFViewer)2 ADialogDialog (org.compiere.apps.ADialogDialog)2 MClient (org.compiere.model.MClient)2