BF [ 1966406 ] Report Engine: AD_PInstance_Logs should be displayed
This commit is contained in:
parent
49fcd69662
commit
364f6b8327
|
@ -55,6 +55,7 @@ public class MQuery implements Serializable
|
|||
// Temporary Tables - add qualifier (not displayed)
|
||||
if (TableName.startsWith("T_"))
|
||||
query.addRestriction(TableName + ".AD_PInstance_ID=" + AD_PInstance_ID);
|
||||
query.m_AD_PInstance_ID = AD_PInstance_ID;
|
||||
|
||||
// How many rows do we have?
|
||||
String SQL = "SELECT COUNT(*) FROM AD_PInstance_Para WHERE AD_PInstance_ID=?";
|
||||
|
@ -329,6 +330,8 @@ public class MQuery implements Serializable
|
|||
|
||||
/** Table Name */
|
||||
private String m_TableName = "";
|
||||
/** PInstance */
|
||||
private int m_AD_PInstance_ID = 0;
|
||||
/** List of Restrictions */
|
||||
private ArrayList<Restriction> m_list = new ArrayList<Restriction>();
|
||||
/** Record Count */
|
||||
|
@ -780,6 +783,12 @@ public class MQuery implements Serializable
|
|||
return newQuery;
|
||||
} // clone
|
||||
|
||||
/**
|
||||
* @return AD_PInstance_ID; this value is set if you created this query by using {@link #get(Properties, int, String)}
|
||||
*/
|
||||
public int getAD_PInstance_ID() {
|
||||
return m_AD_PInstance_ID;
|
||||
}
|
||||
} // MQuery
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.compiere.util.*;
|
|||
* <li>BF [ 1673548 ] Image is not scaled in a report table cell
|
||||
* <li>BF [ 1807917 ] Layout positioning issue with m_maxHeightSinceNewLine
|
||||
* <li>BF [ 1825876 ] Layout boxes with auto width not working
|
||||
* <li>FR [ 1966406 ] Report Engine: AD_PInstance_Logs should be displayed
|
||||
*/
|
||||
public class LayoutEngine implements Pageable, Printable, Doc
|
||||
{
|
||||
|
@ -394,6 +395,14 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
element.setLocation(m_position[AREA_CONTENT]);
|
||||
m_position[AREA_CONTENT].y += element.getHeight() + 5; // GAP
|
||||
}
|
||||
// Process Instance Log (if any):
|
||||
element = layoutPInstanceLogs();
|
||||
if (element != null)
|
||||
{
|
||||
m_currPage.addElement (element);
|
||||
element.setLocation(m_position[AREA_CONTENT]);
|
||||
m_position[AREA_CONTENT].y += element.getHeight() + 5; // GAP
|
||||
}
|
||||
// Table
|
||||
if (m_data != null)
|
||||
{
|
||||
|
@ -1697,6 +1706,23 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
pe.layout(0, 0, false, null);
|
||||
return pe;
|
||||
} // layoutParameter
|
||||
|
||||
/**
|
||||
* Layout Process Instance Logs (if any)
|
||||
* @return PrintElement
|
||||
*/
|
||||
private PrintElement layoutPInstanceLogs()
|
||||
{
|
||||
if (m_query == null || !m_query.isActive() || m_query.getAD_PInstance_ID() <= 0)
|
||||
return null;
|
||||
//
|
||||
PInstanceLogElement e = new PInstanceLogElement(m_printCtx, m_query, m_format.getTableFormat());
|
||||
if (e.getEffectiveRowCount() <= 0) {
|
||||
return null;
|
||||
}
|
||||
e.layout(0, 0, false, null);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.print.layout;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.model.MPInstanceLog;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.X_AD_PInstance_Log;
|
||||
import org.compiere.print.MPrintTableFormat;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>FR [ 1966406 ] Report Engine: AD_PInstance_Logs should be displayed
|
||||
*/
|
||||
public class PInstanceLogElement extends GridElement {
|
||||
private int m_effectiveRowCount = 0;
|
||||
|
||||
public PInstanceLogElement(Properties ctx, MQuery query, MPrintTableFormat tFormat)
|
||||
{
|
||||
super (calculateRowCount(query, ctx), 4);
|
||||
//
|
||||
int AD_PInstance_ID = query.getAD_PInstance_ID();
|
||||
if (AD_PInstance_ID > 0) {
|
||||
MPInstance instance = new MPInstance(ctx, AD_PInstance_ID, null);
|
||||
MPInstanceLog[] logs = instance.getLog();
|
||||
for (int r = 0; r < logs.length; r++) {
|
||||
int col = 0;
|
||||
String msg = logs[r].getP_Msg();
|
||||
if (!Util.isEmpty(msg, true)) {
|
||||
String s = Msg.parseTranslation(ctx, msg);
|
||||
setData (r, col++, s, tFormat.getParameter_Font(), tFormat.getParameter_Color());
|
||||
}
|
||||
BigDecimal num = logs[r].getP_Number();
|
||||
if (num != null) {
|
||||
String s = num.toString();
|
||||
setData (r, col++, s, tFormat.getParameter_Font(), tFormat.getParameter_Color());
|
||||
}
|
||||
Timestamp date = logs[r].getP_Date();
|
||||
if (date != null) {
|
||||
String s = date.toString();
|
||||
setData (r, col++, s, tFormat.getParameter_Font(), tFormat.getParameter_Color());
|
||||
}
|
||||
//
|
||||
if (col > 0)
|
||||
m_effectiveRowCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of rows effectively added
|
||||
*/
|
||||
public int getEffectiveRowCount() {
|
||||
return m_effectiveRowCount;
|
||||
}
|
||||
|
||||
private static int calculateRowCount(MQuery query, Properties ctx) {
|
||||
int AD_PInstance_ID = query.getAD_PInstance_ID();
|
||||
if (AD_PInstance_ID > 0) {
|
||||
String sql = "SELECT COUNT(*) FROM "+X_AD_PInstance_Log.Table_Name
|
||||
+" WHERE "+X_AD_PInstance_Log.COLUMNNAME_AD_PInstance_ID+"=?";
|
||||
int no = DB.getSQLValue(null, sql, AD_PInstance_ID);
|
||||
if (no > 0) {
|
||||
return no;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue