Search in sources :

Example 1 with WReport

use of org.adempiere.webui.apps.WReport in project adempiere by adempiere.

the class AbstractADWindowPanel method onReport.

/**
     * @see ToolbarListener#onReport()
     */
public void onReport() {
    GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
    if (!MRole.getDefault().isCanReport(currentTab.getAD_Table_ID())) {
        FDialog.error(curWindowNo, parent, "AccessCannotReport");
        return;
    }
    if (!onSave(false))
        return;
    //	Query
    //MQuery query = curTabx.getQuery() ; //  new MQuery(curTabx.getTableName());
    //  new MQuery(curTabx.getTableName());
    MQuery oldQuery = currentTab.getQuery();
    MQuery query = new MQuery(currentTab.getTableName());
    try {
        query = oldQuery.deepCopy();
    } catch (Exception e) {
        query = oldQuery;
        e.printStackTrace();
    }
    if (currentTab.getWhereClause() != null) {
        if (currentTab.getWhereClause().length() > 0)
            query.addRestriction(Env.parseContext(ctx, curWindowNo, currentTab.getWhereClause(), false));
    }
    //	Link for detail records
    String queryColumn = currentTab.getLinkColumnName();
    //	Current row otherwise
    if (queryColumn.length() == 0)
        queryColumn = currentTab.getKeyColumnName();
    //	Find display
    String infoName = null;
    String infoDisplay = null;
    for (int i = 0; i < currentTab.getFieldCount(); i++) {
        GridField field = currentTab.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(currentTab.getAD_Table_ID(), query, toolbar.getEvent().getTarget(), curWindowNo);
}
Also used : WReport(org.adempiere.webui.apps.WReport) GridTab(org.compiere.model.GridTab) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) ApplicationException(org.adempiere.webui.exception.ApplicationException)

Aggregations

WReport (org.adempiere.webui.apps.WReport)1 ApplicationException (org.adempiere.webui.exception.ApplicationException)1 GridField (org.compiere.model.GridField)1 GridTab (org.compiere.model.GridTab)1 MQuery (org.compiere.model.MQuery)1