IDEMPIERE-270 Reports should inherit search filter from window - revise create print format item logic and report window popup
This commit is contained in:
parent
f9d68d8320
commit
bf5e689eef
|
@ -578,10 +578,7 @@ public class MPrintFormat extends X_AD_PrintFormat
|
|||
int seqNo = 1;
|
||||
for (GridField gridField : gridFields)
|
||||
{
|
||||
if (gridField.getAD_Column_ID() <= 0)
|
||||
continue;
|
||||
|
||||
MPrintFormatItem pfi = MPrintFormatItem.createFromColumn (pf, gridField.getAD_Column_ID(), seqNo++);
|
||||
MPrintFormatItem pfi = MPrintFormatItem.createFromGridField(pf, gridField, seqNo++);
|
||||
if (pfi != null)
|
||||
{
|
||||
printFormatItemList.add (pfi);
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.X_AD_PrintFormatItem;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -513,6 +514,92 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem
|
|||
// pfi.dump();
|
||||
return pfi;
|
||||
} // createFromColumn
|
||||
|
||||
public static MPrintFormatItem createFromGridField (MPrintFormat format, GridField gridField, int seqNo)
|
||||
{
|
||||
if (gridField.getAD_Column_ID() <= 0)
|
||||
return null;
|
||||
|
||||
MPrintFormatItem pfi = new MPrintFormatItem (format.getCtx(), 0, format.get_TrxName());
|
||||
pfi.setAD_PrintFormat_ID (format.getAD_PrintFormat_ID());
|
||||
pfi.setClientOrg(format);
|
||||
pfi.setAD_Column_ID(gridField.getAD_Column_ID());
|
||||
pfi.setPrintFormatType(PRINTFORMATTYPE_Field);
|
||||
|
||||
// translation is dome by trigger
|
||||
String sql = "SELECT c.ColumnName,e.Name,e.PrintName, " // 1..3
|
||||
+ "c.AD_Reference_ID,c.IsKey,c.SeqNo " // 4..6
|
||||
+ "FROM AD_Column c, AD_Element e "
|
||||
+ "WHERE c.AD_Column_ID=?"
|
||||
+ " AND c.AD_Element_ID=e.AD_Element_ID";
|
||||
// translate base entry if single language - trigger copies to trl tables
|
||||
Language language = format.getLanguage();
|
||||
boolean trl = !Env.isMultiLingualDocument(format.getCtx()) && !language.isBaseLanguage();
|
||||
if (trl)
|
||||
sql = "SELECT c.ColumnName,e.Name,e.PrintName, " // 1..3
|
||||
+ "c.AD_Reference_ID,c.IsKey,c.SeqNo " // 4..6
|
||||
+ "FROM AD_Column c, AD_Element_Trl e "
|
||||
+ "WHERE c.AD_Column_ID=?"
|
||||
+ " AND c.AD_Element_ID=e.AD_Element_ID"
|
||||
+ " AND e.AD_Language=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, format.get_TrxName());
|
||||
pstmt.setInt(1, gridField.getAD_Column_ID());
|
||||
if (trl)
|
||||
pstmt.setString(2, language.getAD_Language());
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
pfi.setName(rs.getString(2));
|
||||
pfi.setPrintName(rs.getString(3));
|
||||
int displayType = rs.getInt(4);
|
||||
if (DisplayType.isNumeric(displayType))
|
||||
pfi.setFieldAlignmentType(FIELDALIGNMENTTYPE_TrailingRight);
|
||||
else if (displayType == DisplayType.Text || displayType == DisplayType.Memo )
|
||||
pfi.setFieldAlignmentType(FIELDALIGNMENTTYPE_Block);
|
||||
else
|
||||
pfi.setFieldAlignmentType(FIELDALIGNMENTTYPE_LeadingLeft);
|
||||
//
|
||||
if (displayType == DisplayType.Button || displayType == DisplayType.Binary
|
||||
|| displayType == DisplayType.ID || displayType == DisplayType.Image
|
||||
|| displayType == DisplayType.RowID
|
||||
|| seqNo == 0)
|
||||
{
|
||||
pfi.setIsPrinted(false);
|
||||
pfi.setSeqNo(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pfi.setIsPrinted(true);
|
||||
pfi.setSeqNo(seqNo);
|
||||
}
|
||||
int idSeqNo = rs.getInt(6); // IsIdentifier SortNo
|
||||
if (idSeqNo > 0)
|
||||
{
|
||||
pfi.setIsOrderBy(true);
|
||||
pfi.setSortNo(idSeqNo);
|
||||
}
|
||||
}
|
||||
else
|
||||
s_log.log(Level.SEVERE, "Not Found AD_Column_ID=" + gridField.getAD_Column_ID()
|
||||
+ " Trl=" + trl + " " + language.getAD_Language());
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
if (!pfi.save())
|
||||
return null;
|
||||
// pfi.dump();
|
||||
return pfi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy existing Definition To Client
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
package org.adempiere.webui.panel;
|
||||
|
||||
import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_REDO;
|
||||
import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_UNDO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
@ -38,7 +41,6 @@ import org.adempiere.webui.WZoomAcross;
|
|||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.BusyDialogTemplate;
|
||||
import org.adempiere.webui.apps.ProcessModalDialog;
|
||||
import org.adempiere.webui.apps.WReport;
|
||||
import org.adempiere.webui.apps.form.WCreateFromFactory;
|
||||
import org.adempiere.webui.apps.form.WCreateFromWindow;
|
||||
import org.adempiere.webui.apps.form.WPayment;
|
||||
|
@ -75,7 +77,6 @@ import org.compiere.model.MProcess;
|
|||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRecentItem;
|
||||
import org.compiere.model.MRole;
|
||||
import static org.compiere.model.SystemIDs.*;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.process.ProcessInfoUtil;
|
||||
|
@ -2070,41 +2071,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
private void onReport0() {
|
||||
ReportAction reportAction = new ReportAction(this);
|
||||
reportAction.show();
|
||||
/* // Query
|
||||
MQuery query = new MQuery(curTab.getTableName());
|
||||
// Link for detail records
|
||||
String queryColumn = curTab.getLinkColumnName();
|
||||
// Current row otherwise
|
||||
if (queryColumn.length() == 0)
|
||||
queryColumn = curTab.getKeyColumnName();
|
||||
// Find display
|
||||
String infoName = null;
|
||||
String infoDisplay = null;
|
||||
for (int i = 0; i < curTab.getFieldCount(); i++)
|
||||
{
|
||||
GridField field = curTab.getField(i);
|
||||
if (field.isKey())
|
||||
infoName = field.getHeader();
|
||||
if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") )
|
||||
&& field.getValue() != null)
|
||||
infoDisplay = field.getValue().toString();
|
||||
if (infoName != null && infoDisplay != null)
|
||||
break;
|
||||
}
|
||||
if (queryColumn.length() != 0)
|
||||
{
|
||||
if (queryColumn.endsWith("_ID"))
|
||||
query.addRestriction(queryColumn, MQuery.EQUAL,
|
||||
new Integer(Env.getContextAsInt(ctx, curWindowNo, queryColumn)),
|
||||
infoName, infoDisplay);
|
||||
else
|
||||
query.addRestriction(queryColumn, MQuery.EQUAL,
|
||||
Env.getContext(ctx, curWindowNo, queryColumn),
|
||||
infoName, infoDisplay);
|
||||
}
|
||||
|
||||
new WReport (curTab.getAD_Table_ID(), query, toolbar.getEvent().getTarget(), curWindowNo, curTab.getWhereExtended());
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.logging.Level;
|
|||
|
||||
import javax.sql.RowSet;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.WProcessCtl;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
|
@ -89,7 +89,6 @@ public class ReportAction implements EventListener<Event>
|
|||
if(winReport == null)
|
||||
{
|
||||
winReport = new Window();
|
||||
winReport.setTitle(Msg.getMsg(Env.getCtx(), "Export") + ": " + panel.getActiveGridTab().getName());
|
||||
winReport.setWidth("450px");
|
||||
winReport.setClosable(true);
|
||||
winReport.setBorder("normal");
|
||||
|
@ -161,7 +160,7 @@ public class ReportAction implements EventListener<Event>
|
|||
}
|
||||
|
||||
winReport.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
AEnv.showWindow(winReport);
|
||||
LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue