Search in sources :

Example 26 with MPrintFormat

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

the class OrderDistributionReceipt method dynInit.

public void dynInit() throws Exception {
    setTitle("MovementGenerateInfo");
    MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
    this.setPrintFormat(format);
    setAskPrintMsg("PrintMovements");
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat)

Example 27 with MPrintFormat

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

the class WPrintDocument method print.

public void print(PO document, String printFormantName, int windowNo) {
    boolean retValue = true;
    if (FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), "PrintShipments")) {
        do {
            try {
                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);
                if (re != null) {
                    SimplePDFViewer win = new SimplePDFViewer(printFormantName, new FileInputStream(re.getPDF()));
                    SessionManager.getAppDesktop().showWindow(win, "center");
                }
            } catch (Exception e) {
            } finally {
                retValue = FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), Msg.getMsg(Env.getCtx(), "PrintoutOK?"));
            }
        } while (!retValue);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) FileInputStream(java.io.FileInputStream)

Example 28 with MPrintFormat

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

the class ReleaseInOutBound method getReportEngine.

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

Example 29 with MPrintFormat

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

the class ZkReportViewer method cmd_report.

/**
	 * 	Report Combo - Start other Report or create new one
	 */
private void cmd_report() {
    Listitem pp = (Listitem) comboReport.getSelectedItem();
    if (pp != null && (int) pp.getValue() >= 0) {
        //	Set Default Report View
        MPrintFormat pf = MPrintFormat.get(Env.getCtx(), (int) pp.getValue(), true);
        selectReportView(pf.getAD_ReportView_ID());
    }
    //	Call Report
    cmd_report(false);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) Listitem(org.zkoss.zul.Listitem)

Example 30 with MPrintFormat

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

the class ZkReportViewer method cmd_report.

/**
	 * 	Report Combo - Start other Report or create new one
	 * 	@param isSummaryChanged for when the check Is Summary is changed
	 */
private void cmd_report(boolean isSummaryChanged) {
    ListItem li = comboReport.getSelectedItem();
    if (li == null || li.getValue() == null)
        return;
    Object pp = li.getValue();
    if (pp == null)
        return;
    //
    MPrintFormat pf = null;
    int AD_PrintFormat_ID = Integer.valueOf(pp.toString());
    //	create new
    if (AD_PrintFormat_ID == -1) {
        int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
        if (AD_ReportView_ID != 0) {
            String name = m_reportEngine.getName();
            int index = name.lastIndexOf('_');
            if (index != -1)
                name = name.substring(0, index);
            pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
        } else {
            int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
            pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
        }
        if (pf != null)
            fillComboReport(pf.get_ID());
        else
            return;
    } else if (AD_PrintFormat_ID == -2) {
        MPrintFormat current = m_reportEngine.getPrintFormat();
        if (current != null) {
            pf = MPrintFormat.copyToClient(m_ctx, current.getAD_PrintFormat_ID(), Env.getAD_Client_ID(m_ctx));
            if (pf != null)
                fillComboReport(pf.get_ID());
            else
                return;
        } else
            return;
    } else
        pf = MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true);
    //	FR [ 238 ]
    if (pf == null)
        return;
    //	
    if (!isSummaryChanged) {
        summary.setSelected(pf.isSummary());
    }
    // Set Summary for report
    m_reportEngine.setSummary(summary.isSelected());
    //	Get Language from previous - thanks Gunther Hoppe 
    if (m_reportEngine.getPrintFormat() != null) {
        //	needs to be re-set - otherwise viewer will be blank
        pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage());
        pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
    }
    //	FR [ 237 ]
    Listitem reportView = (Listitem) comboReportView.getSelectedItem();
    if (reportView != null) {
        m_reportEngine.setAD_ReportView_ID((int) reportView.getValue());
    }
    m_reportEngine.setPrintFormat(pf);
    //	
    try {
        renderReport();
    } catch (Exception e) {
        throw new AdempiereException("Failed to render report", e);
    }
    revalidate();
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) AdempiereException(org.adempiere.exceptions.AdempiereException) Listitem(org.zkoss.zul.Listitem) ListItem(org.adempiere.webui.component.ListItem) SQLException(java.sql.SQLException) AdempiereException(org.adempiere.exceptions.AdempiereException)

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