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

📄 uidealstagedropdown.java

📁 国外的一套开源CRM
💻 JAVA
字号:
/*
 * 
 * Copyright (c) 2004 SourceTap - www.sourcetap.com
 *
 *  The contents of this file are subject to the SourceTap Public License 
 * ("License"); You may not use this file except in compliance with the 
 * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 */

package com.sourcetap.sfa.ui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;

import com.sourcetap.sfa.util.Preference;
import com.sourcetap.sfa.util.UserInfo;


/**
 * DOCUMENT ME!
 *
 */
public class UIDealStageDropDown extends UIDropDown {
	
	public static final String module = UIDealStageDropDown.class.getName();

    public UIDealStageDropDown() {
    }

    /**
     * Return a list of values for a drop down using a UI Display Object defined in the data base.
     * This method overrides the parent class.
     *
     * @author John Nutting
     *
     * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
     * @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
     * @param orderDef List of fields defining the sort order of the drop down values
     * @param entityDetailsVector Vector of generic values containing the values to be displayed on the screen for all fields
     * @param fieldInfo Reference to field info object containing attributes of the current field
     * @param userInfo Reference to user info object containing information about the currently logged-in user
     *
     * @return List of generic values to be displayed in the drop down.  This will be null if an error occurs.
     */
    public List getDropDownValues(GenericDelegator delegator,
        UIDisplayObject uiDisplayObject, ArrayList orderDef,
        Vector entityDetailsVector, UIFieldInfo fieldInfo, UserInfo userInfo) {
        return getDropDownValuesDynamic(delegator, new HashMap(), userInfo);
    }

    /**
     * Return a list of values based on filter criteria.  This is used by the dynamic filtered drop downs
     * which are modified via DHTML.  This method must be overridden in a desdendent class.<BR><BR>Note: This method
     * is only used when the drop down is updated dynamically.
     * When the screen is first displayed, the getDropDownValues method is used.
     *
     * @see #getDropDownValues(GenericDelegator, UIDisplayObject, ArrayList, Vector, UIFieldInfo, UserInfo)
     *
     * @author  <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
     * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
     *
     * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
     * @param filterValues Map containing field/value pairs to be used for filtering the drop down list
     * @param userInfo Reference to user info object containing information about the currently logged-in user
     *
     * @return List of generic values to be displayed in the drop down.  This will be null if an error occurs.
     */
    public List getDropDownValuesDynamic(GenericDelegator delegator,
        Map filterValues, UserInfo userInfo) {
        	
		Preference preference = new Preference(delegator);
		String salesProcess = preference.getPreference(userInfo.getAccountId(),
					"SALES_PROCESS", "standard");
		try {
	
			String dealStageTypeId = "1";
			List dealStageTypeList = delegator.findByAnd("DealStageType", UtilMisc.toMap("accountId", userInfo.getAccountId(), "dealStageTypeName", salesProcess), null);
			if ( dealStageTypeList != null && !dealStageTypeList.isEmpty())
			{
				GenericValue dealStageTypeGV = (GenericValue) dealStageTypeList.get(0);
				dealStageTypeId = dealStageTypeGV.getString("dealStageTypeId");
			}

		   return delegator.findByAnd("DealStage", UtilMisc.toMap("stageTypeId", dealStageTypeId), UtilMisc.toList("stageOrder"));
        } catch (GenericEntityException e) {
            Debug.logError(
                "[UIDealStageDropDown.getDropDownValues] Error retrieving the dropdown values: ", module);
            Debug.logError(e.getLocalizedMessage(), module);

            return new LinkedList();
        }
    }
    
    public static String getDefaultSaleProcessId(GenericDelegator delegator, UserInfo userInfo)
    {
		Preference preference = new Preference(delegator);
		String salesProcess = preference.getPreference(userInfo.getAccountId(),
					"SALES_PROCESS", "standard");
		String dealStageTypeId = "1";

		try {
	
			List dealStageTypeList = delegator.findByAnd("DealStageType", UtilMisc.toMap("accountId", userInfo.getAccountId(), "dealStageTypeName", salesProcess), null);
			if ( dealStageTypeList != null && !dealStageTypeList.isEmpty())
			{
				GenericValue dealStageTypeGV = (GenericValue) dealStageTypeList.get(0);
				dealStageTypeId = dealStageTypeGV.getString("dealStageTypeId");
			}

		} catch (GenericEntityException e) {
			Debug.logError(
				"[UIDealStageDropDown.getDropDownValues] Error retrieving the dropdown values: ", module);
			Debug.logError(e.getLocalizedMessage(), module);
		}
    	
    	return dealStageTypeId;
    }
    
    public static List getDefaultSalesProcessStages(GenericDelegator delegator, UserInfo userInfo)
    {    	
		Preference preference = new Preference(delegator);
		String salesProcess = preference.getPreference(userInfo.getAccountId(),
					"SALES_PROCESS", "standard");
		try {
	
			String dealStageTypeId = "1";
			List dealStageTypeList = delegator.findByAnd("DealStageType", UtilMisc.toMap("accountId", userInfo.getAccountId(), "dealStageTypeName", salesProcess), null);
			if ( dealStageTypeList != null && !dealStageTypeList.isEmpty())
			{
				GenericValue dealStageTypeGV = (GenericValue) dealStageTypeList.get(0);
				dealStageTypeId = dealStageTypeGV.getString("dealStageTypeId");
			}

		   return delegator.findByAnd("DealStage", UtilMisc.toMap("stageTypeId", dealStageTypeId), UtilMisc.toList("stageOrder"));
		} catch (GenericEntityException e) {
			Debug.logError(
				"[UIDealStageDropDown.getDropDownValues] Error retrieving the dropdown values: ", module);
			Debug.logError(e.getLocalizedMessage(), module);

			return new LinkedList();
		}
    }
}

⌨️ 快捷键说明

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