Search in sources :

Example 21 with MPrintFormat

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

the class VGenPanel method generateComplete.

/**
	 *  Complete generating shipments/invoices.
	 *  Called from Unlock UI
	 *  @param pi process info
	 */
public void generateComplete(ProcessInfo pi) {
    //  Switch Tabs
    tabbedPane.setSelectedIndex(1);
    //
    ProcessInfoUtil.setLogFromDB(pi);
    StringBuffer iText = new StringBuffer();
    iText.append("<b>").append(pi.getSummary()).append("</b><br>(").append(Msg.getMsg(Env.getCtx(), genForm.getTitle())).append(")<br>").append(pi.getLogInfo(true));
    info.setText(iText.toString());
    //	Reset Selection
    /*
		String sql = "UPDATE C_Order SET IsSelected='N' WHERE " + m_whereClause;
		int no = DB.executeUpdate(sql, null);
		log.config("Reset=" + no);*/
    //	Get results
    int[] ids = pi.getIDs();
    if (ids == null || ids.length == 0)
        return;
    log.config("PrintItems=" + ids.length);
    confirmPanelGen.getOKButton().setEnabled(false);
    //	OK to print
    if (ADialog.ask(m_WindowNo, this, genForm.getAskPrintMsg())) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        //	see also ProcessDialog.printShipments/Invoices
        int retValue = ADialogDialog.A_CANCEL;
        do {
            //	Loop through all items
            for (int i = 0; i < ids.length; i++) {
                int Record_ID = ids[i];
                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, Record_ID);
                    //	Engine
                    PrintInfo info = new PrintInfo(table.getTableName(), table.get_Table_ID(), Record_ID);
                    ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
                    re.print();
                    new Viewer(m_frame.getGraphicsConfiguration(), re);
                } else
                    ReportCtl.startDocumentPrint(genForm.getReportEngineType(), Record_ID, this, Env.getWindowNo(this), true);
            }
            //	Yamel Senih 2015-11-23 FR [ 114 ] Add Supoort to dynamic create from
            ADialogDialog d = new ADialogDialog(m_frame.getCFrame(), Env.getHeader(Env.getCtx(), m_WindowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
            //	End Yamel Senih
            retValue = d.getReturnCode();
        } while (retValue == ADialogDialog.A_CANCEL);
        this.setCursor(Cursor.getDefaultCursor());
    }
    //	OK to print
    //
    confirmPanelGen.getOKButton().setEnabled(true);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) MTable(org.compiere.model.MTable) ADialogDialog(org.compiere.apps.ADialogDialog) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Viewer(org.compiere.print.Viewer)

Example 22 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 23 with MPrintFormat

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

the class WReport method createNewFormat.

//	getPrintFormats
/**
	 * 	Create and Launch new Format for table
	 * 	@param AD_Table_ID table
	 */
private File createNewFormat(int AD_Table_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
    WebSessionCtx wsc = WebSessionCtx.get(request);
    MPrintFormat pf = MPrintFormat.createFromTable(wsc.ctx, AD_Table_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 24 with MPrintFormat

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

the class VOrderDistributionReceipt method generateMovements_complete.

/**
	 *  Complete generating movements.
	 * @param movement
	 */
private void generateMovements_complete(MMovement movement) {
    //  Switch Tabs
    tabbedPane.setSelectedIndex(1);
    StringBuffer iText = new StringBuffer();
    iText.append("<b>").append("").append("</b><br>").append(Msg.translate(Env.getCtx(), "DocumentNo") + " : " + movement.getDocumentNo()).append("<br>").append("");
    info.setText(iText.toString());
    confirmPanelGen.getOKButton().setEnabled(false);
    //	OK to print shipments
    if (ADialog.ask(m_WindowNo, this, "PrintShipments")) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        //	see also ProcessDialog.printShipments/Invoices
        int retValue = ADialogDialog.A_CANCEL;
        do {
            MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
            MQuery query = new MQuery(MMovement.Table_Name);
            query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, movement.getM_Movement_ID());
            //	Engine
            PrintInfo info = new PrintInfo(MMovement.Table_Name, MMovement.Table_ID, movement.getM_Movement_ID());
            ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
            re.print();
            new Viewer(re);
            //	Yamel Senih FR [ 114 ] 2015-11-23
            ADialogDialog d = new ADialogDialog(m_frame.getCFrame(), Env.getHeader(Env.getCtx(), m_WindowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
            retValue = d.getReturnCode();
        } while (retValue == ADialogDialog.A_CANCEL);
        setCursor(Cursor.getDefaultCursor());
    }
    //	OK to print shipments
    //
    confirmPanelGen.getOKButton().setEnabled(true);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) ADialogDialog(org.compiere.apps.ADialogDialog) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Viewer(org.compiere.print.Viewer)

Example 25 with MPrintFormat

use of org.compiere.print.MPrintFormat 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

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