Examples of MClient


Examples of org.compiere.model.MClient

      + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) "
      + "WHERE tt.AD_Table_ID=? "
      + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)";
    int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID);
    // ASP
    MClient client = MClient.get(Env.getCtx());
    String ASPFilter = "";
    if (client.isUseASP())
      ASPFilter =
        "     AND (   AD_Tab_ID IN ( "
        // Just ASP subscribed tabs for client "
        + "              SELECT t.AD_Tab_ID "
        + "                FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
        + "               WHERE w.ASP_Level_ID = l.ASP_Level_ID "
        + "                 AND cl.AD_Client_ID = " + client.getAD_Client_ID()
        + "                 AND cl.ASP_Level_ID = l.ASP_Level_ID "
        + "                 AND t.ASP_Window_ID = w.ASP_Window_ID "
        + "                 AND t.IsActive = 'Y' "
        + "                 AND w.IsActive = 'Y' "
        + "                 AND l.IsActive = 'Y' "
        + "                 AND cl.IsActive = 'Y' "
        + "                 AND t.ASP_Status = 'S') " // Show
        + "        OR AD_Tab_ID IN ( "
        // + show ASP exceptions for client
        + "              SELECT AD_Tab_ID "
        + "                FROM ASP_ClientException ce "
        + "               WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
        + "                 AND ce.IsActive = 'Y' "
        + "                 AND ce.AD_Tab_ID IS NOT NULL "
        + "                 AND ce.AD_Field_ID IS NULL "
        + "                 AND ce.ASP_Status = 'S') " // Show
        + "       ) "
        + "   AND AD_Tab_ID NOT IN ( "
        // minus hide ASP exceptions for client
        + "          SELECT AD_Tab_ID "
        + "            FROM ASP_ClientException ce "
        + "           WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
        + "             AND ce.IsActive = 'Y' "
        + "             AND ce.AD_Tab_ID IS NOT NULL "
        + "             AND ce.AD_Field_ID IS NULL "
        + "             AND ce.ASP_Status = 'H')"; // Hide
    //
View Full Code Here

Examples of org.compiere.model.MClient

    //  Too broad selection
    if (m_C_BPartner_ID == 0 && m_C_Invoice_ID == 0 && m_dateInvoiced_From == null && m_dateInvoiced_To == null
      && m_DocumentNo_From == null && m_DocumentNo_To == null)
      throw new AdempiereUserError ("@RestrictSelection@");

    MClient client = MClient.get(getCtx());
   
    //  Get Info
    StringBuffer sql = new StringBuffer (
      "SELECT i.C_Invoice_ID,bp.AD_Language,c.IsMultiLingualDocument,"    //  1..3
      //  1/07/09 rgliddon:  Added Unapproved Invoice Print Format
      //  Prio: 1. BPartner 2. DocType, 3. Unapproved Invoice Print Format (Org)
      //        4. PrintFormat (Org)  //  see ReportCtl+MInvoice
      + " COALESCE(bp.Invoice_PrintFormat_ID, dt.AD_PrintFormat_ID,"
                    +"CASE WHEN i.posted IS NULL OR i.posted = 'N' "
                         +"THEN pf.UnaprvdInvoice_PrintFormat_ID "
                    +"END, pf.Invoice_PrintFormat_ID),"  //  4
      + " dt.DocumentCopies+bp.DocumentCopies,"                //  5
      + " bpc.AD_User_ID, i.DocumentNo,"                    //  6..7
      + " bp.C_BPartner_ID "                          //  8
      + "FROM C_Invoice i"
      + " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)"
      + " LEFT OUTER JOIN AD_User bpc ON (i.AD_User_ID=bpc.AD_User_ID)"
      + " INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)"
      + " INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)"
      + " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
        + " WHERE i.AD_Client_ID=? AND i.AD_Org_ID=? AND i.isSOTrx='Y' AND "
        + "       pf.AD_Org_ID IN (0,i.AD_Org_ID) AND " )//  more them 1 PF
    boolean needAnd = false;
    if (m_C_Invoice_ID != 0)
      sql.append("i.C_Invoice_ID=").append(m_C_Invoice_ID);
    else
    {
      if (m_C_BPartner_ID != 0)
      {
        sql.append ("i.C_BPartner_ID=").append (m_C_BPartner_ID);
        needAnd = true;
      }
      if (m_dateInvoiced_From != null && m_dateInvoiced_To != null)
      {
        if (needAnd)
          sql.append(" AND ");
        sql.append("TRUNC(i.DateInvoiced) BETWEEN ")
          .append(DB.TO_DATE(m_dateInvoiced_From, true)).append(" AND ")
          .append(DB.TO_DATE(m_dateInvoiced_To, true));
        needAnd = true;
      }
      else if (m_dateInvoiced_From != null)
      {
        if (needAnd)
          sql.append(" AND ");
        sql.append("TRUNC(i.DateInvoiced) >= ")
          .append(DB.TO_DATE(m_dateInvoiced_From, true));
        needAnd = true;
      }
      else if (m_dateInvoiced_To != null)
      {
        if (needAnd)
          sql.append(" AND ");
        sql.append("TRUNC(i.DateInvoiced) <= ")
          .append(DB.TO_DATE(m_dateInvoiced_To, true));
        needAnd = true;
      }
      else if (m_DocumentNo_From != null && m_DocumentNo_To != null)
      {
        if (needAnd)
          sql.append(" AND ");
        sql.append("i.DocumentNo BETWEEN ")
          .append(DB.TO_STRING(m_DocumentNo_From)).append(" AND ")
          .append(DB.TO_STRING(m_DocumentNo_To));
      }
      else if (m_DocumentNo_From != null)
      {
        if (needAnd)
          sql.append(" AND ");
        if (m_DocumentNo_From.indexOf('%') == -1)
          sql.append("i.DocumentNo >= ")
            .append(DB.TO_STRING(m_DocumentNo_From));
        else
          sql.append("i.DocumentNo LIKE ")
            .append(DB.TO_STRING(m_DocumentNo_From));
      }
     
      if (p_EMailPDF)
      {
        if (needAnd)
        {
          sql.append(" AND ");
        }
        /* if emailed to customer only select COmpleted & CLosed invoices */
        sql.append("i.DocStatus IN ('CO','CL') ");
      }
    }
    sql.append(" ORDER BY i.C_Invoice_ID, pf.AD_Org_ID DESC")//  more than 1 PF record
    log.fine(sql.toString());

    MPrintFormat format = null;
    int old_AD_PrintFormat_ID = -1;
    int old_C_Invoice_ID = -1;
    int C_BPartner_ID = 0;
    int count = 0;
    int errors = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
   
    try
    {
      pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
      pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
      pstmt.setInt(2, Env.getAD_Org_ID(Env.getCtx()));
      rs = pstmt.executeQuery();
     
      while (rs.next())
      {
        int C_Invoice_ID = rs.getInt(1);
        if (C_Invoice_ID == old_C_Invoice_ID//  multiple pf records
          continue;
        old_C_Invoice_ID = C_Invoice_ID;
        //  Set Language when enabled
        Language language = Language.getLoginLanguage();    //  Base Language
        String AD_Language = rs.getString(2);
        if (AD_Language != null && "Y".equals(rs.getString(3)))
          language = Language.getLanguage(AD_Language);
        //
        int AD_PrintFormat_ID = rs.getInt(4);
        int copies = rs.getInt(5);
        if (copies == 0)
          copies = 1;
        int AD_User_ID = rs.getInt(6);
        MUser to = new MUser (getCtx(), AD_User_ID, get_TrxName());
        String DocumentNo = rs.getString(7);
        C_BPartner_ID = rs.getInt(8);
        //
        String documentDir = client.getDocumentDir();
        if (documentDir == null || documentDir.length() == 0)
          documentDir = ".";
        //
        if (p_EMailPDF && (to.get_ID() == 0 || to.getEMail() == null || to.getEMail().length() == 0))
        {
          addLog (C_Invoice_ID, null, null, DocumentNo + " @RequestActionEMailNoTo@");
          errors++;
          continue;
        }
        if (AD_PrintFormat_ID == 0)
        {
          addLog (C_Invoice_ID, null, null, DocumentNo + " No Print Format");
          errors++;
          continue;
        }
        //  Get Format & Data
        if (AD_PrintFormat_ID != old_AD_PrintFormat_ID)
        {
          format = MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false);
          old_AD_PrintFormat_ID = AD_PrintFormat_ID;
        }
        format.setLanguage(language);
        format.setTranslationLanguage(language);
        //  query
        MQuery query = new MQuery("C_Invoice_Header_v");
        query.addRestriction("C_Invoice_ID", MQuery.EQUAL, new Integer(C_Invoice_ID));

        //  Engine
        PrintInfo info = new PrintInfo(
          DocumentNo,
          X_C_Invoice.Table_ID,
          C_Invoice_ID,
          C_BPartner_ID);
        info.setCopies(copies);
        ReportEngine re = new ReportEngine(getCtx(), format, query, info);
        boolean printed = false;
        if (p_EMailPDF)
        {
          String subject = mText.getMailHeader() + " - " + DocumentNo;
          EMail email = client.createEMail(to.getEMail(), subject, null);
          if (!email.isValid())
          {
            addLog (C_Invoice_ID, null, null,
              DocumentNo + " @RequestActionEMailError@ Invalid EMail: " + to);
            errors++;
View Full Code Here

Examples of org.compiere.model.MClient

      + ",DateValue=" + p_DateValue
      + ",M_PriceList_Version_ID=" + p_M_PriceList_Version_ID
      + ",M_CostElement_ID=" + p_M_CostElement_ID);
   
    MWarehouse wh = MWarehouse.get(getCtx(), p_M_Warehouse_ID);
    MClient c = MClient.get(getCtx(), wh.getAD_Client_ID());
    MAcctSchema as = c.getAcctSchema();

    //  Delete (just to be sure)
    StringBuffer sql = new StringBuffer ("DELETE T_InventoryValue WHERE AD_PInstance_ID=");
    sql.append(getAD_PInstance_ID());
    int no = DB.executeUpdateEx(sql.toString(), get_TrxName());
View Full Code Here

Examples of org.compiere.model.MClient

    int C_BPartner_ID = 0;
    String DocumentNo = null;
    int copies = 1;

    //  Language
    MClient client = MClient.get(ctx);
    Language language = client.getLanguage()
    //  Get Document Info
    String sql = null;
    if (type == CHECK)
      sql = "SELECT bad.Check_PrintFormat_ID,"                //  1
        + "  c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo "    //  2..5
View Full Code Here

Examples of org.compiere.model.MClient

      throw new AdempiereUserError ("@NotFound@ @M_CostElement_ID@ (Future) " + p_SetFutureCostTo);
    if (!isValid(p_SetStandardCostTo))
      throw new AdempiereUserError ("@NotFound@ @M_CostElement_ID@ (Standard) " + p_SetStandardCostTo);

    //  Prepare
    MClient client = MClient.get(getCtx());
    m_ce = MCostElement.getMaterialCostElement(client, MAcctSchema.COSTINGMETHOD_StandardCosting);
    if (m_ce.get_ID() == 0)
      throw new AdempiereUserError ("@NotFound@ @M_CostElement_ID@ (StdCost)");
    log.config(m_ce.toString());
    m_ass = MAcctSchema.getClientAcctSchema(getCtx(), client.getAD_Client_ID());
    for (int i = 0; i < m_ass.length; i++)
      createNew(m_ass[i]);
    commit();
   
    //  Update Cost
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.