Search in sources :

Example 91 with MQuery

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

the class HtmlDashboard method createHTML.

private String createHTML(PAGE_TYPE requestPage) {
    String result = "<html><head>";
    // READ CSS
    URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
    InputStreamReader ins;
    try {
        ins = new InputStreamReader(url.openStream());
        BufferedReader bufferedReader = new BufferedReader(ins);
        String cssLine;
        result += "<style type=\"text/css\">";
        while ((cssLine = bufferedReader.readLine()) != null) result += cssLine + "\n";
        result += "</style>";
    } catch (IOException e1) {
        log.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
    }
    //System.out.println(result);
    switch(requestPage) {
        case PAGE_LOGO:
            result += "</head><body class=\"header\">" + "<table width=\"100%\"><tr><td>" + "<img src=\"res:org/compiere/images/logo_ad.png\">" + "</td><td></td><td width=\"290\">" + //+ "<img src=\"res:at/freecom/apps/images/logo_fc.png\">"
            "</td></tr></table>" + "</body></html>";
            break;
        case //**************************************************************
        PAGE_HOME:
            // "<link rel=\"stylesheet\" type=\"text/css\" href=\"file:///c:/standard.css\"/>"
            result += "</head><body><div class=\"content\">\n";
            queryZoom = null;
            queryZoom = new ArrayList<MQuery>();
            String appendToHome = null;
            try {
                for (final MDashboardContent dp : MDashboardContent.getForSession()) {
                    if (!Util.isEmpty(dp.getZulFilePath(), true))
                        continue;
                    //
                    appendToHome = dp.getHTML();
                    if (appendToHome != null) {
                        if (dp.getDescription() != null)
                            result += "<H2>" + dp.getDescription() + "</H2>\n";
                        result += stripHtml(appendToHome, false) + "<br>\n";
                    }
                    if (dp.getAD_Menu_ID() > 0) {
                        result += "<a class=\"hrefNode\" href=\"http:///window/node#" + String.valueOf(// "AD_MENU_ID") fcsku 3.7.07
                        dp.getAD_Window_ID() + "\">" + dp.getDescription() + "</a><br>\n");
                    }
                    result += "<br>\n";
                    //result += "table id: " + rs.getInt("AD_TABLE_ID");
                    if (dp.getPA_Goal_ID() > 0)
                        result += goalsDetail(dp.getPA_Goal_ID());
                }
            } catch (Exception e) {
                log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            } finally {
            }
            result += "<br><br><br>\n" + "</div>\n</body>\n</html>\n";
            break;
        default:
            //************************************************************** 
            log.warning("Unknown option - " + requestPage);
    }
    return result;
}
Also used : MDashboardContent(org.compiere.model.MDashboardContent) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) MQuery(org.compiere.model.MQuery) IOException(java.io.IOException) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 92 with MQuery

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

the class VGenPanel method generateComplete.

/**
	 *  Complete generating shipments/invoices.
	 *  Called from Unlock UI
	 *  @param pi process info
	 */
public void generateComplete(ProcessInfo pi) {
    //  Switch Tabs
    tabbedPane.setSelectedIndex(1);
    //
    ProcessInfoUtil.setLogFromDB(pi);
    StringBuffer iText = new StringBuffer();
    iText.append("<b>").append(pi.getSummary()).append("</b><br>(").append(Msg.getMsg(Env.getCtx(), genForm.getTitle())).append(")<br>").append(pi.getLogInfo(true));
    info.setText(iText.toString());
    //	Reset Selection
    /*
		String sql = "UPDATE C_Order SET IsSelected='N' WHERE " + m_whereClause;
		int no = DB.executeUpdate(sql, null);
		log.config("Reset=" + no);*/
    //	Get results
    int[] ids = pi.getIDs();
    if (ids == null || ids.length == 0)
        return;
    log.config("PrintItems=" + ids.length);
    confirmPanelGen.getOKButton().setEnabled(false);
    //	OK to print
    if (ADialog.ask(m_WindowNo, this, genForm.getAskPrintMsg())) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        //	see also ProcessDialog.printShipments/Invoices
        int retValue = ADialogDialog.A_CANCEL;
        do {
            //	Loop through all items
            for (int i = 0; i < ids.length; i++) {
                int Record_ID = ids[i];
                if (genForm.getPrintFormat() != null) {
                    MPrintFormat format = genForm.getPrintFormat();
                    MTable table = MTable.get(Env.getCtx(), format.getAD_Table_ID());
                    MQuery query = new MQuery(table.getTableName());
                    query.addRestriction(table.getTableName() + "_ID", MQuery.EQUAL, Record_ID);
                    //	Engine
                    PrintInfo info = new PrintInfo(table.getTableName(), table.get_Table_ID(), Record_ID);
                    ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
                    re.print();
                    new Viewer(m_frame.getGraphicsConfiguration(), re);
                } else
                    ReportCtl.startDocumentPrint(genForm.getReportEngineType(), Record_ID, this, Env.getWindowNo(this), true);
            }
            //	Yamel Senih 2015-11-23 FR [ 114 ] Add Supoort to dynamic create from
            ADialogDialog d = new ADialogDialog(m_frame.getCFrame(), Env.getHeader(Env.getCtx(), m_WindowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
            //	End Yamel Senih
            retValue = d.getReturnCode();
        } while (retValue == ADialogDialog.A_CANCEL);
        this.setCursor(Cursor.getDefaultCursor());
    }
    //	OK to print
    //
    confirmPanelGen.getOKButton().setEnabled(true);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) MTable(org.compiere.model.MTable) ADialogDialog(org.compiere.apps.ADialogDialog) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Viewer(org.compiere.print.Viewer)

Example 93 with MQuery

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

the class VAccountDialog method action_Find.

//	statusChanged
/**
	 *	Action Find.
	 *	- create where clause
	 *	- query database
	 *  @param includeAliasCombination include alias combination
	 */
private void action_Find(boolean includeAliasCombination) {
    log.info("");
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    //	Create where Clause
    MQuery query = null;
    if (m_query != null)
        query = m_query.deepCopy();
    else
        query = new MQuery();
    //	Alias
    if (includeAliasCombination && f_Alias != null && f_Alias.getValue().toString().length() > 0) {
        String value = f_Alias.getValue().toString().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        query.addRestriction("UPPER(Alias)", MQuery.LIKE, value);
    }
    //	Combination (mandatory)
    if (includeAliasCombination && f_Combination.getValue().toString().length() > 0) {
        String value = f_Combination.getValue().toString().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        query.addRestriction("UPPER(Combination)", MQuery.LIKE, value);
    }
    //	Org (mandatory)
    if (f_AD_Org_ID != null && f_AD_Org_ID.getValue() != null)
        query.addRestriction("AD_Org_ID", MQuery.EQUAL, f_AD_Org_ID.getValue());
    //	Account (mandatory)
    if (f_Account_ID != null && f_Account_ID.getValue() != null)
        query.addRestriction("Account_ID", MQuery.EQUAL, f_Account_ID.getValue());
    if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null)
        query.addRestriction("C_SubAcct_ID", MQuery.EQUAL, f_SubAcct_ID.getValue());
    //	Product
    if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
        query.addRestriction("M_Product_ID", MQuery.EQUAL, f_M_Product_ID.getValue());
    //	BPartner
    if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
        query.addRestriction("C_BPartner_ID", MQuery.EQUAL, f_C_BPartner_ID.getValue());
    //	Campaign
    if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
        query.addRestriction("C_Campaign_ID", MQuery.EQUAL, f_C_Campaign_ID.getValue());
    //	Loc From
    if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
        query.addRestriction("C_LocFrom_ID", MQuery.EQUAL, f_C_LocFrom_ID.getValue());
    //	Loc To
    if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
        query.addRestriction("C_LocTo_ID", MQuery.EQUAL, f_C_LocTo_ID.getValue());
    //	Project
    if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
        query.addRestriction("C_Project_ID", MQuery.EQUAL, f_C_Project_ID.getValue());
    //	SRegion
    if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
        query.addRestriction("C_SalesRegion_ID", MQuery.EQUAL, f_C_SalesRegion_ID.getValue());
    //	Org Trx
    if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
        query.addRestriction("AD_OrgTrx_ID", MQuery.EQUAL, f_AD_OrgTrx_ID.getValue());
    //	Activity
    if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
        query.addRestriction("C_Activity_ID", MQuery.EQUAL, f_C_Activity_ID.getValue());
    //	User 1
    if (f_User1_ID != null && f_User1_ID.getValue() != null)
        query.addRestriction("User1_ID", MQuery.EQUAL, f_User1_ID.getValue());
    //	User 2
    if (f_User2_ID != null && f_User2_ID.getValue() != null)
        query.addRestriction("User2_ID", MQuery.EQUAL, f_User2_ID.getValue());
    //	User 3
    if (f_User3_ID != null && f_User3_ID.getValue() != null)
        query.addRestriction("User3_ID", MQuery.EQUAL, f_User3_ID.getValue());
    //	User 4
    if (f_User4_ID != null && f_User4_ID.getValue() != null)
        query.addRestriction("User4_ID", MQuery.EQUAL, f_User4_ID.getValue());
    //	Query
    m_mTab.setQuery(query);
    m_mTab.query(false);
    statusBar.setStatusDB(String.valueOf(m_mTab.getRowCount()));
    setCursor(Cursor.getDefaultCursor());
}
Also used : MQuery(org.compiere.model.MQuery)

Example 94 with MQuery

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

the class WReport method doGet.

//  init
/**
	 * Process the HTTP Get request
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.fine("doGet");
    log.info(response.toString());
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    m_curTab = ws.curTab;
    //
    WebDoc doc = null;
    File file = null;
    if (ws == null) {
        doc = WebDoc.createPopup("No Context");
        doc.addPopupClose(wsc.ctx);
    } else /**else if (fileName!=null)
		{			
			int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
			File file = new File (fileName);
			String error = WebUtil.streamFile(response, file);
			if (error == null)
				return;
			doc = WebDoc.createWindow(error);
		}**/
    {
        log.info("");
        if (!MRole.getDefault().isCanReport(ws.curTab.getAD_Table_ID())) {
            doc = WebDoc.createPopup("Access Cannot Report");
            doc.addPopupClose(wsc.ctx);
        }
        //	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(wsc.ctx, m_curTab.getWindowNo(), queryColumn)), infoName, infoDisplay);
            else
                query.addRestriction(queryColumn, MQuery.EQUAL, Env.getContext(wsc.ctx, m_curTab.getWindowNo(), queryColumn), infoName, infoDisplay);
        }
        file = getPrintFormats(m_curTab.getAD_Table_ID(), request, m_curTab, query);
        String error = WebUtil.streamFile(response, file);
        if (error == null)
            return;
        doc = WebDoc.createWindow(error);
    }
    //
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : WebDoc(org.compiere.util.WebDoc) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Example 95 with MQuery

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

the class VOrderDistributionReceipt method generateMovements_complete.

/**
	 *  Complete generating movements.
	 * @param movement
	 */
private void generateMovements_complete(MMovement movement) {
    //  Switch Tabs
    tabbedPane.setSelectedIndex(1);
    StringBuffer iText = new StringBuffer();
    iText.append("<b>").append("").append("</b><br>").append(Msg.translate(Env.getCtx(), "DocumentNo") + " : " + movement.getDocumentNo()).append("<br>").append("");
    info.setText(iText.toString());
    confirmPanelGen.getOKButton().setEnabled(false);
    //	OK to print shipments
    if (ADialog.ask(m_WindowNo, this, "PrintShipments")) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        //	see also ProcessDialog.printShipments/Invoices
        int retValue = ADialogDialog.A_CANCEL;
        do {
            MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
            MQuery query = new MQuery(MMovement.Table_Name);
            query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, movement.getM_Movement_ID());
            //	Engine
            PrintInfo info = new PrintInfo(MMovement.Table_Name, MMovement.Table_ID, movement.getM_Movement_ID());
            ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
            re.print();
            new Viewer(re);
            //	Yamel Senih FR [ 114 ] 2015-11-23
            ADialogDialog d = new ADialogDialog(m_frame.getCFrame(), Env.getHeader(Env.getCtx(), m_WindowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
            retValue = d.getReturnCode();
        } while (retValue == ADialogDialog.A_CANCEL);
        setCursor(Cursor.getDefaultCursor());
    }
    //	OK to print shipments
    //
    confirmPanelGen.getOKButton().setEnabled(true);
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) ADialogDialog(org.compiere.apps.ADialogDialog) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Viewer(org.compiere.print.Viewer)

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