Search in sources :

Example 31 with MPrintFormat

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

the class GenerateReplenishPlanReport method getPrintFormat.

/**
	 * @return
	 */
private MPrintFormat getPrintFormat() {
    MPrintFormat pf = null;
    if (Ini.isClient()) {
        pf = (MPrintFormat) getProcessInfo().getTransientObject();
    } else {
        pf = (MPrintFormat) getProcessInfo().getSerializableObject();
    }
    if (pf == null) {
        pf = MPrintFormat.get(getCtx(), 0, MTable.getTable_ID("M_ReplenishPlanLine"));
    }
    int count = pf.getItemCount();
    int weeksToDisplay = END_WEEK - START_WEEK + 1;
    int startIndx = START_WEEK;
    int endIndx = END_WEEK;
    for (int i = 0; i < count; i++) {
        MPrintFormatItem pfi = pf.getItem(i);
        String columnName = pfi.getColumnName().toLowerCase();
        if (columnName != null && columnName.startsWith("week")) {
            int index = Integer.parseInt(columnName.substring(4));
            if (index > weeksToDisplay) {
                if (pfi.isPrinted())
                    pfi.setIsPrinted(false);
            } else {
                int displayWeek = startIndx + (index - 1);
                String printName = weekDateInfo.get(displayWeek);
                pfi.setPrintName(printName);
                pfi.setIsPrinted(true);
                pfi.setIsSuppressNull(false);
                pfi.setIsSuppressRepeats(false);
                pfi.setMaxWidth(35);
                pfi.setIsFixedWidth(true);
                pfi.setIsHeightOneLine(false);
                // pfi.set_ValueOfColumn("DisplayLogic", "@" + columnName +
                // "@!0");
                pfi.setLineAlignmentType(X_AD_PrintFormatItem.LINEALIGNMENTTYPE_TrailingRight);
                pfi.setFieldAlignmentType(X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight);
                // Dynamic sequencing is required as we are showing & hiding
                // elements based on week difference.
                pfi.setSeqNo(50 + index * 10);
                if (displayWeek > (startIndx + 1) && displayWeek < (endIndx - 1)) {
                    pfi.setAD_PrintColor_ID(RED_AD_PrintColor_ID);
                } else {
                    pfi.setAD_PrintColor_ID(-1);
                }
            }
        }
        pfi.saveEx();
        log.fine(pfi.toString());
    }
    pf.setTranslation();
    // no
    pf = MPrintFormat.get(getCtx(), pf.getAD_PrintFormat_ID(), true);
    // cache
    return pf;
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) MPrintFormatItem(org.compiere.print.MPrintFormatItem)

Example 32 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 33 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 File launchReport(KeyNamePair pp, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
    WebSessionCtx wsc = WebSessionCtx.get(request);
    MPrintFormat pf = MPrintFormat.get(wsc.ctx, pp.getKey(), false);
    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 34 with MPrintFormat

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

the class WReport method createNewFormat.

/**
	 * 	Create and Launch new Format for table
	 * 	@param AD_Table_ID table
	 */
private void createNewFormat(int AD_Table_ID) {
    MPrintFormat pf = MPrintFormat.createFromTable(Env.getCtx(), AD_Table_ID);
    launchReport(pf);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat)

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