IDEMPIERE-4779 : Dashboard / Report : parameters are wrongly displayed (#690)
* IDEMPIERE-4779 : Dashboard / Report : parameters are wrongly displayed * IDEMPIERE-4779 : Dashboard / Report : parameters are wrongly displayed Avoid usage of DisplayType.IsID * IDEMPIERE-4779 : Dashboard / Report : parameters are wrongly displayed AD_Reference_Value_ID can be used for search/table/tabledir * IDEMPIERE-4779 : Dashboard / Report : parameters are wrongly displayed Use MLookupInfo.QueryDirect to display value
This commit is contained in:
parent
cbfb704cb9
commit
9a21b84055
|
@ -53,10 +53,14 @@ import org.compiere.model.MDashboardContent;
|
|||
import org.compiere.model.MDashboardContentAccess;
|
||||
import org.compiere.model.MDashboardPreference;
|
||||
import org.compiere.model.MGoal;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MMenu;
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.model.MPInstancePara;
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.MProcessPara;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
@ -964,8 +968,7 @@ public class DashboardController implements EventListener<Event> {
|
|||
}
|
||||
|
||||
// Convert to Type
|
||||
if (DisplayType.isNumeric(iPara.getDisplayType())
|
||||
|| DisplayType.isID(iPara.getDisplayType()))
|
||||
if (DisplayType.isNumeric(iPara.getDisplayType()))
|
||||
{
|
||||
BigDecimal bd = null;
|
||||
if (value instanceof BigDecimal)
|
||||
|
@ -985,6 +988,17 @@ public class DashboardController implements EventListener<Event> {
|
|||
iPara.setInfo(info);
|
||||
}
|
||||
}
|
||||
else if (iPara.getDisplayType() == DisplayType.Search || iPara.getDisplayType() == DisplayType.Table || iPara.getDisplayType() == DisplayType.TableDir) {
|
||||
int id = new BigDecimal (value.toString()).intValue();
|
||||
if (isTo) {
|
||||
iPara.setP_Number_To(new BigDecimal (value.toString()));
|
||||
iPara.setInfo_To(getDisplay(pInstance, iPara, id));
|
||||
}
|
||||
else {
|
||||
iPara.setP_Number(new BigDecimal (value.toString()));
|
||||
iPara.setInfo(getDisplay(pInstance, iPara, id));
|
||||
}
|
||||
}
|
||||
else if (DisplayType.isDate(iPara.getDisplayType()))
|
||||
{
|
||||
Timestamp ts = null;
|
||||
|
@ -1021,7 +1035,53 @@ public class DashboardController implements EventListener<Event> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getDisplay(MPInstance i, MPInstancePara ip, int id) {
|
||||
try {
|
||||
MProcessPara pp = MProcess.get(i.getAD_Process_ID()).getParameter(ip.getParameterName());
|
||||
|
||||
if (pp != null) {
|
||||
|
||||
MLookupInfo mli = MLookupFactory.getLookupInfo(Env.getCtx(), 0, 0, pp.getAD_Reference_ID(), Env.getLanguage(Env.getCtx()), "", pp.getAD_Reference_Value_ID(), false, "");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
StringBuilder name = new StringBuilder("");
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(mli.QueryDirect, null);
|
||||
pstmt.setInt(1, id);
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
name.append(rs.getString(3));
|
||||
boolean isActive = rs.getString(4).equals("Y");
|
||||
if (!isActive)
|
||||
name.insert(0, MLookup.INACTIVE_S).append(MLookup.INACTIVE_E);
|
||||
|
||||
if (rs.next())
|
||||
logger.log(Level.SEVERE, "Error while displaying parameter for embedded report - Not unique (first returned) for SQL=" + mli.QueryDirect);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Error while displaying parameter for embedded report - " + mli.KeyColumn + ": SQL=" + mli.QueryDirect + " : " + e);
|
||||
}
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
return name.toString();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Failed to retrieve data to display for embedded report " + MProcess.get(i.getAD_Process_ID()).getName() + " : " + ip.getParameterName(), e);
|
||||
}
|
||||
|
||||
return Integer.toString(id);
|
||||
}
|
||||
|
||||
public void updateLayout(ClientInfo clientInfo) {
|
||||
if (isShowInDashboard) {
|
||||
if (ClientInfo.isMobile()) {
|
||||
|
|
Loading…
Reference in New Issue