Search in sources :

Example 76 with Query

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

the class A_Depreciation_Exp_Check method getAsset_IDs.

private int[] getAsset_IDs() {
    ArrayList<Object> params = new ArrayList<Object>();
    String whereClause = null;
    if (p_A_Asset_ID > 0) {
        whereClause = "A_Asset_ID=?";
        params.add(p_A_Asset_ID);
    } else {
        whereClause = p_WhereClause;
    }
    return new Query(getCtx(), MAsset.Table_Name, whereClause, get_TrxName()).setParameters(params).setOrderBy("A_Asset_ID").getIDs();
}
Also used : Query(org.compiere.model.Query) ArrayList(java.util.ArrayList)

Example 77 with Query

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

the class ImportEmployeeAttributes method getAttributeIds.

/**
         * Get Import Attribute List
         * @param isImported
         * @param isProcessed
         * @return
         */
private int[] getAttributeIds(boolean isImported, boolean isProcessed, String trxName) {
    StringBuilder whereClause = new StringBuilder();
    whereClause.append(I_I_HR_Attribute.COLUMNNAME_I_IsImported).append("=? AND ").append(I_I_HR_Attribute.COLUMNNAME_Processed).append("=?");
    return new Query(getCtx(), X_I_HR_Attribute.Table_Name, whereClause.toString(), trxName).setOnlyActiveRecords(true).setParameters(isImported, isProcessed).getIDs();
}
Also used : Query(org.compiere.model.Query)

Example 78 with Query

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

the class PayrollViaEMail method sendIndividualMail.

//	sendBPGroup
/**
	 * 	Send Individual Mail
	 *	@param bPartnerId user
	 *	@param unSubscribe unsubscribe message
	 *	@return true if mail has been sent
	 */
private Boolean sendIndividualMail(int bPartnerId, String unSubscribe) {
    try {
        MBPartner employee = new MBPartner(getCtx(), bPartnerId, null);
        String message = mailText.getMailText(true);
        if (unSubscribe != null)
            message += unSubscribe;
        StringBuffer whereClause = new StringBuffer();
        whereClause.append(MBPartnerLocation.COLUMNNAME_C_BPartner_ID).append(" = ? AND ").append(MBPartnerLocation.COLUMNNAME_ContactType).append("=?");
        MBPartnerLocation location = new Query(getCtx(), MBPartnerLocation.Table_Name, whereClause.toString(), get_TrxName()).setOnlyActiveRecords(true).setParameters(bPartnerId, MBPartnerLocation.CONTACTTYPE_Primary).first();
        if (location == null) {
            addLog(0, null, null, employee.getName() + " @Email@ @NotFound@");
            return false;
        }
        MClient client = MClient.get(getCtx());
        String eMailFrom = client.getRequestEMail();
        String emailFrom = location.get_ValueAsString("EMail");
        String userMailFrom = client.getRequestUser();
        String password = client.getRequestUserPW();
        //	FR [ 402 ]
        //	Add support to new send mail
        EMail email = new EMail(client, eMailFrom, emailFrom, mailText.getMailHeader(), message);
        if (mailText.isHtml())
            email.setMessageHTML(mailText.getMailHeader(), message);
        else {
            email.setSubject(mailText.getMailHeader());
            email.setMessageText(message);
        }
        email.addAttachment(CreatePDF(bPartnerId));
        if (!email.isValid() && !email.isValid(true)) {
            log.warning("NOT VALID - " + email);
            employee.setIsActive(false);
            employee.save();
            return Boolean.FALSE;
        }
        email.createAuthenticator(userMailFrom, password);
        boolean OK = EMail.SENT_OK.equals(email.send());
        if (OK) {
            addLog(0, null, null, employee.getName() + " @Email@ @OK@");
            log.fine(employee.getURL());
        } else
            log.warning("FAILURE - " + employee.getURL());
        addLog(0, null, null, (OK ? "@OK@" : "@ERROR@") + " - " + emailFrom);
        return OK;
    } catch (Exception e) {
        return Boolean.FALSE;
    }
}
Also used : Query(org.compiere.model.Query) MBPartner(org.compiere.model.MBPartner) EMail(org.compiere.util.EMail) MBPartnerLocation(org.compiere.model.MBPartnerLocation) MClient(org.compiere.model.MClient)

Example 79 with Query

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

the class MHRSalaryStructure method getByValue.

/**
     * Get Salary Structure by search key
     * @param ctx
     * @param value
     * @return
     */
public static MHRSalaryStructure getByValue(Properties ctx, String value) {
    if (value == null)
        return null;
    if (salaryStructureCacheValues.size() == 0)
        getAll(ctx, true);
    int clientId = Env.getAD_Client_ID(ctx);
    String key = clientId + "#" + value;
    MHRSalaryStructure salaryStructure = new Query(ctx, Table_Name, COLUMNNAME_Value + "=?", null).setClient_ID().setParameters(key).first();
    if (salaryStructure != null && salaryStructure.getHR_SalaryStructure_ID() > 0) {
        salaryStructureCacheValues.put(key, salaryStructure);
        salaryStructureCacheIds.put(salaryStructure.get_ID(), salaryStructure);
    }
    return salaryStructure;
}
Also used : Query(org.compiere.model.Query)

Example 80 with Query

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

the class HRCreateInvoice method getPayrollMovement.

/**
     * Get Payroll movement with concept is paid and is invoiced
     * @param processId
     * @param partnerId
     * @param trxName
     * @return
     */
private List<MHRMovement> getPayrollMovement(int processId, int partnerId, String trxName) {
    StringBuilder whereClause = new StringBuilder();
    whereClause.append("HR_Movement.HR_Process_ID = ? AND HR_Movement.C_BPartner_ID=? AND ").append("EXISTS (SELECT 1 FROM HR_Concept c INNER JOIN HR_Attribute a ON (c.HR_Concept_ID = a.HR_Concept_ID) ").append("WHERE HR_Movement.C_InvoiceLine_ID IS NULL AND c.HR_Concept_ID=HR_Movement.HR_Concept_ID AND  a.IsActive = ? AND c.IsPaid=? AND c.IsInvoiced=? AND a.C_DocType_ID > 0 AND a.C_Charge_ID > 0)");
    return new Query(getCtx(), MHRMovement.Table_Name, whereClause.toString(), trxName).setClient_ID().setParameters(processId, partnerId, true, true, true).list();
}
Also used : Query(org.compiere.model.Query)

Aggregations

Query (org.compiere.model.Query)210 ArrayList (java.util.ArrayList)49 BigDecimal (java.math.BigDecimal)25 Properties (java.util.Properties)22 MProduct (org.compiere.model.MProduct)20 AdempiereException (org.adempiere.exceptions.AdempiereException)12 MTable (org.compiere.model.MTable)12 MOrderLine (org.compiere.model.MOrderLine)8 MWarehouse (org.compiere.model.MWarehouse)8 PO (org.compiere.model.PO)8 MBPartner (org.compiere.model.MBPartner)6 MQuery (org.compiere.model.MQuery)6 MPPProductBOM (org.eevolution.model.MPPProductBOM)6 MColumn (org.compiere.model.MColumn)5 MLocation (org.compiere.model.MLocation)5 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)5 SQLException (java.sql.SQLException)4 Timestamp (java.sql.Timestamp)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 MClient (org.compiere.model.MClient)4