⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forecast.jsp

📁 国外的一套开源CRM
💻 JSP
📖 第 1 页 / 共 3 页
字号:
<%@ page import="org.ofbiz.entity.*" %>
<%@ page import="org.ofbiz.entity.condition.*" %>
<%@ page import="org.ofbiz.entity.model.*" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.Map.Entry" %>
<%@ page import="java.text.*" %>
<%@ page import="java.math.*" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="org.ofbiz.entity.util.SequenceUtil" %>
<%@ page import="com.sourcetap.sfa.forecast.ForecastHelper" %>
<%@ page import="com.sourcetap.sfa.security.SecurityWrapper" %>
<%@ page import="com.sourcetap.sfa.role.RoleHelper" %>
<%@ page import="com.sourcetap.sfa.replication.*" %>
<%@ page import="com.sourcetap.sfa.util.Preference" %>
<%@ page import="com.sourcetap.sfa.product.ProductHelper" %>
<%@ page import="com.sourcetap.sfa.util.EntityHelper" %>
<%@page import="com.sourcetap.sfa.activity.CalendarUtil" %>


<%@ page import="java.io.*" %>

<%@ include file="/includes/header.jsp" %>

<%!
  double computeQuotaPercent(double firstNum, double secNum){
    if(secNum==0) return 0.0;
    DecimalFormat decimalFormat = new DecimalFormat("#.##");
    return Double.valueOf(decimalFormat.format(firstNum / secNum)).doubleValue();
  }

  Double calculateAmountOfProducts(List opCol){
    GenericValue oppProds[] = (GenericValue[])opCol.toArray(new GenericValue[0]);
    GenericValue oppProd = null;
    double returnAmount = 0.0;
    for(int i=0;i<oppProds.length;i++){
      oppProd = oppProds[i];
      if(oppProd.get("amount") != null){
        returnAmount = returnAmount + oppProd.getDouble("amount").doubleValue();
      }
    }
    return new Double(returnAmount);
  }

  double sumDealProductsForProductCategory(List deals, List opportunityProduct, List products, String productCategory){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    GenericValue oppValues[] = (GenericValue[])opportunityProduct.toArray(new GenericValue[0]);
    GenericValue oppValue = null;
    GenericValue productValues[] = (GenericValue[])products.toArray(new GenericValue[0]);
    GenericValue productValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("useProductsForAmount") != null && dealsValue.getString("useProductsForAmount").equalsIgnoreCase("Y")){
        for(int j=0;j<oppValues.length;j++){
          oppValue = oppValues[j];
          if(oppValue.getString("dealId").equals(dealsValue.getString("dealId"))){
            for(int k=0;k<productValues.length;k++){
              productValue = productValues[k];
              if(productValue.getString("productId").equals(oppValue.getString("productId"))){
                if(productValue.getString("primaryProductCategoryId").equals(productCategory)){
                  returnDouble = returnDouble + oppValue.getDouble("amount").doubleValue();
                }
              }
            }
          }
        }
      }
    }
    return returnDouble;
  }

  double sumDealProductsForStatusAndProductCategory(List deals, List opportunityProduct, List products, String status, String productCategory){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    GenericValue oppValues[] = (GenericValue[])opportunityProduct.toArray(new GenericValue[0]);
    GenericValue oppValue = null;
    GenericValue productValues[] = (GenericValue[])products.toArray(new GenericValue[0]);
    GenericValue productValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealStatusId") != null && dealsValue.getString("dealStatusId").equals(status)){
        if(dealsValue.getString("useProductsForAmount") != null && dealsValue.getString("useProductsForAmount").equalsIgnoreCase("Y")){
          for(int j=0;j<oppValues.length;j++){
            oppValue = oppValues[j];
            if(oppValue.getString("dealId").equals(dealsValue.getString("dealId"))){
              for(int k=0;k<productValues.length;k++){
                productValue = productValues[k];
                if(productValue.getString("productId").equals(oppValue.getString("productId"))){
                  if(productValue.getString("primaryProductCategoryId").equals(productCategory)){
                    returnDouble = returnDouble + oppValue.getDouble("amount").doubleValue();
                  }
                }
              }
            }
          }
        }
      }
    }
    return returnDouble;
  }

  double sumAllDealAmountsForStatus(List deals, List opportunityProduct, List products, String status){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    GenericValue oppValues[] = (GenericValue[])opportunityProduct.toArray(new GenericValue[0]);
    GenericValue oppValue = null;
    GenericValue productValues[] = (GenericValue[])products.toArray(new GenericValue[0]);
    GenericValue productValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealStatusId") != null && dealsValue.getString("dealStatusId").equals(status)){
        if(dealsValue.getString("useProductsForAmount") != null && dealsValue.getString("useProductsForAmount").equals("Y")){
          for(int j=0;j<oppValues.length;j++){
            oppValue = oppValues[j];
            if(oppValue.getString("dealId").equals(dealsValue.getString("dealId"))){
              for(int k=0;k<productValues.length;k++){
                productValue = productValues[k];
                if(productValue.getString("productId").equals(oppValue.getString("productId"))){
                  returnDouble = returnDouble + oppValue.getDouble("amount").doubleValue();
                }
              }
            }
          }
        } else {
          returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
        }
      }
    }
    return returnDouble;
  }
  double sumAllDealAmountsForStatus(List deals, String status){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealStatusId") != null && dealsValue.getString("dealStatusId").equals(status))
	 returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
    }
    return returnDouble;
  }

  int countDealsForStatus(List deals, String status){
    int returnInt = 0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealStatusId") != null && dealsValue.getString("dealStatusId").equals(status)){
        returnInt++;
      }
    }
    return returnInt;
  }

  double sumDealAmountsForStatusWithoutProducts(List deals, String status){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealStatusId") != null && dealsValue.getString("dealStatusId").equals(status)){
        if(dealsValue.getString("useProductsForAmount") == null || !dealsValue.getString("useProductsForAmount").equals("Y")){
          returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
        }
      }
    }
    return returnDouble;
  }

  double sumDealAmountsWithoutProducts(List deals){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
        if(dealsValue.getString("useProductsForAmount") == null || !dealsValue.getString("useProductsForAmount").equals("Y")){
          returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
        }
    }
    return returnDouble;
  }

  double getAmountForDeal(List deals, List opportunityProduct, List products, String dealId){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    GenericValue oppValues[] = (GenericValue[])opportunityProduct.toArray(new GenericValue[0]);
    GenericValue oppValue = null;
    GenericValue productValues[] = (GenericValue[])products.toArray(new GenericValue[0]);
    GenericValue productValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealId").equals(dealId)){
        if(dealsValue.getString("useProductsForAmount") != null && dealsValue.getString("useProductsForAmount").equals("Y")){
          for(int j=0;j<oppValues.length;j++){
            oppValue = oppValues[j];
            if(oppValue.getString("dealId").equals(dealsValue.getString("dealId"))){
              for(int k=0;k<productValues.length;k++){
                productValue = productValues[k];
                if(productValue.getString("productId").equals(oppValue.getString("productId"))){
                  returnDouble = returnDouble + oppValue.getDouble("amount").doubleValue();
                }
              }
            }
          }
        } else {
          returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
        }
      }
    }
    return returnDouble;
  }

  double getAmountForDeal(List deals, String dealId){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("dealId").equals(dealId))
        returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
    }
    return returnDouble;
  }

  double sumAllDeals(List deals, List opportunityProduct, List products){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;
    GenericValue oppValues[] = (GenericValue[])opportunityProduct.toArray(new GenericValue[0]);
    GenericValue oppValue = null;
    GenericValue productValues[] = (GenericValue[])products.toArray(new GenericValue[0]);
    GenericValue productValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      if(dealsValue.getString("useProductsForAmount") != null && dealsValue.getString("useProductsForAmount").equals("Y")){
        for(int j=0;j<oppValues.length;j++){
          oppValue = oppValues[j];
          if(oppValue.getString("dealId").equals(dealsValue.getString("dealId"))){
            for(int k=0;k<productValues.length;k++){
              productValue = productValues[k];
              if(productValue.getString("productId").equals(oppValue.getString("productId"))){
                returnDouble = returnDouble + oppValue.getDouble("amount").doubleValue();
              }
            }
          }
        }
      } else {
        returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
      }
    }
    return returnDouble;
  }

  double sumAllDeals(List deals ){
    double returnDouble = 0.0;
    GenericValue dealsValues[] = (GenericValue[])deals.toArray(new GenericValue[0]);
    GenericValue dealsValue = null;

    for(int i=0;i<dealsValues.length;i++){
      dealsValue = dealsValues[i];
      returnDouble = returnDouble + dealsValue.getDouble("amount").doubleValue();
    }
    return returnDouble;
  }

	GenericValue getAccount(GenericDelegator delegator, String accountId, Map accountMap )
	{
		 GenericValue acctGV = null;         
         if ( accountId != null )
         {
         	acctGV = (GenericValue) accountMap.get(accountId);
         	if ( acctGV == null )
         	{
         		try {
         		  acctGV = delegator.findByPrimaryKey(new GenericPK(delegator.getModelEntity("Account"), UtilMisc.toMap("accountId",accountId)));
         		}
         		catch ( Exception e)
         		{
         			Debug.logError(e, "forecast");
         		}
         		if ( acctGV != null )
         		{
         			accountMap.put(accountId, acctGV );
         		} 
         	}         	
         } 
	     return acctGV;
	}

%>


<%
   String userName = userInfo.getUserFullName();
   Preference pref = Preference.getInstance(delegator);
   String opportunityHasProductsString = pref.getPreference(userInfo.getAccountId(), "OPPORTUNITY_PRODUCTS", "yes");
   
   int fyStartMonth = CalendarUtil.getFiscalYearStartMonth( delegator, userInfo );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -