Search in sources :

Example 71 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class Page method getDrillDown.

//	paint
/*************************************************************************/
/**
	 * 	Get DrillDown value
	 * 	@param relativePoint relative Point
	 * 	@return if found NamePait or null
	 */
public MQuery getDrillDown(Point relativePoint) {
    MQuery retValue = null;
    for (int i = 0; i < m_elements.size() && retValue == null; i++) {
        PrintElement element = (PrintElement) m_elements.get(i);
        retValue = element.getDrillDown(relativePoint, m_pageNo);
    }
    return retValue;
}
Also used : MQuery(org.compiere.model.MQuery) Point(java.awt.Point)

Example 72 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class ARequest method actionPerformed.

//	getZoomTargets
/**
	 * 	Listner
	 *	@param e event
	 */
public void actionPerformed(ActionEvent e) {
    MQuery query = null;
    if (e.getSource() == m_active) {
        query = new MQuery("");
        String where = "(" + m_where + ") AND Processed='N'";
        query.addRestriction(where);
        query.setRecordCount(0);
    } else if (e.getSource() == m_all) {
        query = new MQuery("");
        query.addRestriction(m_where.toString());
        query.setRecordCount(0);
    } else if (e.getSource() == m_new) {
        query = new MQuery("");
        query.addRestriction("1=2");
        query.setRecordCount(0);
    }
    //
    //	232=all - 201=my
    int AD_Window_ID = 232;
    AWindow frame = new AWindow(m_graphicsconfig);
    if (!frame.initWindow(AD_Window_ID, query))
        return;
    AEnv.addToWindowManager(frame);
    //	New - set Table/Record
    if (e.getSource() == m_new) {
        GridTab tab = frame.getAPanel().getCurrentTab();
        tab.dataNew(false);
        tab.setValue("AD_Table_ID", new Integer(m_AD_Table_ID));
        tab.setValue("Record_ID", new Integer(m_Record_ID));
        //
        if (m_C_BPartner_ID != 0)
            tab.setValue("C_BPartner_ID", new Integer(m_C_BPartner_ID));
        //
        if (m_AD_Table_ID == I_C_BPartner.Table_ID)
            tab.setValue("C_BPartner_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_AD_User.Table_ID)
            tab.setValue("AD_User_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Project.Table_ID)
            tab.setValue("C_Project_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_A_Asset.Table_ID)
            tab.setValue("A_Asset_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Order.Table_ID)
            tab.setValue("C_Order_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_C_Invoice.Table_ID)
            tab.setValue("C_Invoice_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_M_Product.Table_ID)
            tab.setValue("M_Product_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_C_Payment.Table_ID)
            tab.setValue("C_Payment_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_M_InOut.Table_ID)
            tab.setValue("M_InOut_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_M_RMA.Table_ID)
            tab.setValue("M_RMA_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Campaign.Table_ID)
            tab.setValue("C_Campaign_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_R_Request.Table_ID)
            tab.setValue(MRequest.COLUMNNAME_R_RequestRelated_ID, new Integer(m_Record_ID));
        else // FR [2842165] - Order Ref link from SO line creating new request
        if (m_AD_Table_ID == I_C_OrderLine.Table_ID) {
            MOrderLine oLine = new MOrderLine(Env.getCtx(), m_Record_ID, null);
            if (oLine != null) {
                tab.setValue(MOrderLine.COLUMNNAME_C_Order_ID, new Integer(oLine.getC_Order_ID()));
            }
        }
    }
    AEnv.showCenterScreen(frame);
    frame = null;
}
Also used : GridTab(org.compiere.model.GridTab) MQuery(org.compiere.model.MQuery) MOrderLine(org.compiere.model.MOrderLine)

Example 73 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class APanel method cmd_report.

//  cmd_refresh
/**
	 *	Print standard Report
	 */
private void cmd_report() {
    log.info("");
    if (!MRole.getDefault().isCanReport(m_curTab.getAD_Table_ID())) {
        ADialog.error(m_curWindowNo, this, "AccessCannotReport");
        return;
    }
    cmd_save(false);
    //	Query
    MQuery query = new MQuery(m_curTab.getTableName());
    //	Link for detail records
    String queryColumn = m_curTab.getLinkColumnName();
    //	Current row otherwise
    if (queryColumn.length() == 0)
        queryColumn = m_curTab.getKeyColumnName();
    //	Find display
    String infoName = null;
    String infoDisplay = null;
    for (int i = 0; i < m_curTab.getFieldCount(); i++) {
        GridField field = m_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(m_ctx, m_curWindowNo, queryColumn)), infoName, infoDisplay);
        else
            query.addRestriction(queryColumn, MQuery.EQUAL, Env.getContext(m_ctx, m_curWindowNo, queryColumn), infoName, infoDisplay);
    }
    new AReport(m_curTab.getAD_Table_ID(), aReport.getButton(), query, this, m_curWindowNo, m_curTab.getWhereExtended());
}
Also used : AReport(org.compiere.print.AReport) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) Point(java.awt.Point)

Example 74 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class APanel method doZoomToDetail.

private boolean doZoomToDetail(GridTab gTab, MQuery query, int tabIndex) {
    GridField[] fields = gTab.getFields();
    for (GridField field : fields) {
        if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName())) {
            m_mWorkbench.getMWindow(0).initTab(tabIndex);
            int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
            if (parentId > 0) {
                Map<Integer, Object[]> parentMap = new TreeMap<Integer, Object[]>();
                int index = tabIndex;
                int oldpid = parentId;
                GridTab currentTab = gTab;
                while (index > 0) {
                    index--;
                    GridTab pTab = m_mWorkbench.getMWindow(0).getTab(index);
                    if (pTab.getTabLevel() < currentTab.getTabLevel()) {
                        m_mWorkbench.getMWindow(0).initTab(index);
                        if (index > 0) {
                            if (pTab.getLinkColumnName() != null && pTab.getLinkColumnName().trim().length() > 0) {
                                int pid = DB.getSQLValue(null, "SELECT " + pTab.getLinkColumnName() + " FROM " + pTab.getTableName() + " WHERE " + currentTab.getLinkColumnName() + " = ?", oldpid);
                                if (pid > 0) {
                                    parentMap.put(index, new Object[] { currentTab.getLinkColumnName(), oldpid });
                                    oldpid = pid;
                                    currentTab = pTab;
                                } else {
                                    parentMap.clear();
                                    break;
                                }
                            }
                        } else {
                            parentMap.put(index, new Object[] { currentTab.getLinkColumnName(), oldpid });
                        }
                    }
                }
                for (Map.Entry<Integer, Object[]> entry : parentMap.entrySet()) {
                    GridTab pTab = m_mWorkbench.getMWindow(0).getTab(entry.getKey());
                    Object[] value = entry.getValue();
                    MQuery pquery = new MQuery(pTab.getAD_Table_ID());
                    pquery.addRestriction((String) value[0], "=", value[1]);
                    pTab.setQuery(pquery);
                    GridController gc = (GridController) tabPanel.getComponentAt(entry.getKey());
                    gc.activate();
                    gc.query(false, 0, 0);
                }
                MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
                targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId);
                gTab.setQuery(targetQuery);
                GridController gc = null;
                if (!includedMap.containsKey(gTab.getAD_Tab_ID())) {
                    int target = tabPanel.findTabindex(gTab);
                    gc = (GridController) tabPanel.getComponentAt(target);
                } else {
                    GridController parent = includedMap.get(gTab.getAD_Tab_ID());
                    gc = parent.findChild(gTab);
                }
                gc.activate();
                gc.query(false, 0, 0);
                GridTable table = gTab.getTableModel();
                int count = table.getRowCount();
                for (int i = 0; i < count; i++) {
                    int id = table.getKeyID(i);
                    if (id == ((Integer) query.getZoomValue()).intValue()) {
                        if (!includedMap.containsKey(gTab.getAD_Tab_ID())) {
                            tabPanel.setSelectedIndex(tabPanel.findTabindex(gTab));
                        } else {
                            GridController parent = includedMap.get(gTab.getAD_Tab_ID());
                            int pindex = tabPanel.findTabindex(parent.getMTab());
                            if (pindex >= 0)
                                tabPanel.setSelectedIndex(pindex);
                        }
                        gTab.navigate(i);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : GridTable(org.compiere.model.GridTable) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) TreeMap(java.util.TreeMap) Point(java.awt.Point) GridTab(org.compiere.model.GridTab) GridController(org.compiere.grid.GridController) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 75 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class APanel method cmd_zoomAcross.

//	cmd_report
/**
	 * 	Zoom Across Menu
	 */
private void cmd_zoomAcross() {
    int record_ID = m_curTab.getRecord_ID();
    log.info("ID=" + record_ID);
    if (record_ID <= 0)
        return;
    //	Query
    MQuery query = new MQuery();
    //	Current row
    String link = m_curTab.getKeyColumnName();
    //	Link for detail records
    if (link.length() == 0)
        link = m_curTab.getLinkColumnName();
    if (link.length() != 0) {
        if (link.endsWith("_ID"))
            query.addRestriction(link, MQuery.EQUAL, new Integer(Env.getContextAsInt(m_ctx, m_curWindowNo, link)));
        else
            query.addRestriction(link, MQuery.EQUAL, Env.getContext(m_ctx, m_curWindowNo, link));
    }
    new AZoomAcross(aZoomAcross.getButton(), m_curTab.getTableName(), m_curTab.getAD_Window_ID(), query);
}
Also used : MQuery(org.compiere.model.MQuery) Point(java.awt.Point)

Aggregations

MQuery (org.compiere.model.MQuery)109 PrintInfo (org.compiere.model.PrintInfo)19 GridField (org.compiere.model.GridField)15 MPrintFormat (org.compiere.print.MPrintFormat)14 ReportEngine (org.compiere.print.ReportEngine)12 Point (java.awt.Point)11 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)9 GridWindowVO (org.compiere.model.GridWindowVO)9 SQLException (java.sql.SQLException)8 GridTab (org.compiere.model.GridTab)8 GridWindow (org.compiere.model.GridWindow)7 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 AWindow (org.compiere.apps.AWindow)6 File (java.io.File)5 IOException (java.io.IOException)5 Language (org.compiere.util.Language)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MClient (org.compiere.model.MClient)3 MLookup (org.compiere.model.MLookup)3