/**
 * @(#)file    InputText.java
 * @(#)author  chj
 * @(#)version 1.0
 * @(#)date    2014. 6. 24.
 * @(#)since   JDK 1.6
 *
 * Copyright (c)  www.udapsoft.co.kr, Inc.
 */
package com.udapsoft.waf.common.ui;

import java.util.StringTokenizer;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.util.StringUtil;
import kr.co.hsnc.common.util.ValueObject;

public class InputText {

    /**
     * - 속성 -
     * ID            : 영문자와 숫자만 입력가능
     * Password      : 입력문자를 숨김
     * ReadOnly      : 읽기전용
     * Number        : 숫자만 입력가능
     * Float         : 숫자와 소수점 입력가능
     * Minus         : 음수도 입력가능
     * Date          : 숫자만 입력가능
     * Time          : 숫자만 입력가능
     * TEL           : 숫자와 '-'만 입력가능
     * Hangule       : 입력시 한글
     * Required      : 필수항목 표시(단순히 표시만 함)
     * Left          : 왼쪽 정렬
     * Right         : 오른쪽 정렬
     * Center        : 중앙 정렬
     * AutoTab       : MaxLength 만큼 입력하면 자동으로 Focus 이동
     * tabIndex=n    : Input tag 에 tabIndex 속성을 지정합니다.-> tabIndex=2
     * class=name    : CSS 의 클래스명을 지정 Default : input
     * 
     * - Mask -
     * Number       : 999,999,999 형태로 변환
     * Float        : 999,999.9999 형태로 변환
     * Date         : YYYY-MM-DD 형태로 변환
     * Time         : 24:00 형태로 변환
     */



    private static String requiredStyle = "";
    private static String hanguleStyle  = "IME-MODE : active;";
    private static String englishStyle  = "IME-MODE : inactive;";
    private static String rightStyle    = "text-align : right;";
    private static String centerStyle   = "text-align : center;";
    private static String readOnlyColor = "#dedede";
    /*private static String readOnlyStyle = "BORDER-COLOR : #ababab; BACKGROUND-COLOR : ";*/
    private static String readOnlyStyle = "BORDER-COLOR : #cbcbcb; BACKGROUND-COLOR :#f0f0f0; ";
    private static String numStyle      = "IME-MODE : disabled;";

    private static String numberKeyUpEvent = " this.value=doKeyUpEvent(this.value, 'NUMBER');";
    private static String floatKeyUpEvent = " this.value=doKeyUpEvent(this.value, 'FLOAT');";
    private static String numberMinusKeyUpEvent = " this.value=doKeyUpEvent(this.value, 'NUMBER_MINUS');";
    private static String floatMinusKeyUpEvent = " this.value=doKeyUpEvent(this.value, 'FLOAT_MINUS');";
    private static String numberKeyPressEvent = " doKeyPressEvent(this, 'NUMBER');";
    private static String floatKeyPressEvent  = " doKeyPressEvent(this, 'FLOAT');";
	private static String numberMinusKeyPressEvent = " doKeyPressEvent(this, 'NUMBER_MINUS');";
	private static String floatMinusKeyPressEvent  = " doKeyPressEvent(this, 'FLOAT_MINUS');";
	private static String englishKeyPressEvent  = " doKeyPressEvent(this, 'ENGLISH');";
	
    private static String idKeyPressEvent     = " doKeyPressEvent(this, 'ID');";
    private static String telKeyPressEvent    = " doKeyPressEvent(this, 'TEL');";

    private static String autoTabKeyUpEvent  = "autoTab(this, this.maxLength);";
    private static String enterTabKeyUpEvent = "enterKeyPress(this);";


    
    private static String numberFloatMaskFocusEvent = "doNumberFloatFocusEvent(this);";
	
    private static String numberFloatMaskBlurEvent  = "doNumberFloatBlurEvent(this);";


    private static String dateMaskFocusEvent = "doDateFocusEvent(this);";
    private static String dateMaskBlurEvent  = "doDateBlurEvent(this);";

    private static String timeMaskFocusEvent = "doTimeFocusEvent(this);";
    private static String timeMaskBlurEvent  = "doTimeBlurEvent(this);";

    private static String minMaxBlurEvent = "doCheckMinMaxValue(this); ";

    private String  type       = "";
    private String  name       = "";
    private String  value      = "";
    private int     size       = 15;
    private int     maxLength  = 15;
    private String  mask       = "";
    private String  etcAttrs   = "";

    private String  minValue   = "";
    private String  maxValue   = "";
    
    private String  descName   = "";

    
    // Attributes
    private boolean isID         = false;
    private boolean isPassword   = false;
    private boolean isTel        = false;
    private boolean isReadOnly   = false;
    private boolean isNumber     = false;
    private boolean isFloat      = false;
	private boolean isMinus      = false;
    private boolean isDate       = false;
    private boolean isTime       = false;
    private boolean isHangule    = false;
    private boolean isEnglish    = false;
    private boolean isRequired   = false;
    private boolean isRight      = false;
    private boolean isCenter     = false;
    private boolean isAutoTab    = false;
    private boolean isTabIndex   = false; private int tabIndex = 0;
    private boolean isEnterTab   = false;
    private boolean isMinValue   = false;
    private boolean isMaxValue   = false;
    private boolean isPercentageSize = false;


    private String attrsStyle = "";
    private String className = "input";
    
    private boolean m_isMakeTD = false ;

    private String readOnlyColorTemp = readOnlyColor;
    
    public static String getString(String name, String value, int size, int maxLength, String attributes) {
        return StringUtil.replace(get(name, value, size, maxLength, attributes), "\"", "\\\"");
    }

    public static String getString(String name, String value, int size, int maxLength, String attributes, String mask) {
        return StringUtil.replace(get(name, value, size, maxLength, attributes, mask), "\"", "\\\"");
    }

    public static String getString(String name, String value, int size, int maxLength, String attributes, String mask, String etcAttrs) {
        return StringUtil.replace(get(name, value, size, maxLength, attributes, mask, etcAttrs), "\"", "\\\"");
    }

    public static String get(String name, String value, int size, int maxLength, String attributes) {
        return get(name, value, size, maxLength, attributes, "");
    }

    public static String get(String name, String value, int size, int maxLength, String attributes, String mask) {
        return get(name, value, size, maxLength, attributes, mask, "");
    }

    public static String get(String name, String value, int size, int maxLength, String attributes, String mask, String etcAttrs) {
        InputText inputText = new InputText(name, value, size, maxLength, attributes, mask, etcAttrs);
        return inputText.getInputTag();
    }

    public static String get(String name, String value, String altName, int size, int maxLength, String attributes) {
        return get(name, value, altName, size, maxLength, attributes, "", "");
    }
    
    public static String get(String name, String value, String altName, int size, int maxLength, String attributes, String mask) {
        return get(name, value, altName, size, maxLength, attributes, mask, "");
    }
    
    public static String get(String name, String value, String altName, int size, int maxLength, String attributes, String mask, String etcAttrs) {
        if( !"".equals(altName) && altName != null ) {
            if( etcAttrs == null )
                etcAttrs = "";
            etcAttrs += " alt='" + altName + "'";
        }
        InputText inputText = new InputText(name, value, size, maxLength, attributes, mask, etcAttrs);
        return inputText.getInputTag();
    }


    private InputText(String name, String value,int size, int maxLength, String attributes, String mask, String etcAttrs) {

        this.name      = ( name  == null ? "" : name  );
        this.value     = ( value == null ? "" : value );
        this.mask      = ( mask  == null ? "" : mask.trim()  );
        this.etcAttrs  = ( etcAttrs == null ? "" : etcAttrs.trim() );
        this.size      = size;
        this.maxLength = maxLength;
        
        
        String[] attrsArray = getTokenArray(attributes, ",");

        if( attrsArray != null && attrsArray.length != 0 ) {

            for( int i = 0 ; i < attrsArray.length ; i++ ) {
                
                if( attrsArray[i].equalsIgnoreCase("ID") ) {
                	this.isID = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("password") ) {
                	this.isPassword = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("tel") ) {
                	this.isTel = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("number") ) {
                	this.isNumber = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("float") ) {
                	this.isFloat = true;
                    continue;
                }

				if( attrsArray[i].equalsIgnoreCase("minus") ) {
					this.isMinus = true;
					continue;
				}

                if( attrsArray[i].equalsIgnoreCase("date") ) {
                	this.isDate = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("time") ) {
                	this.isTime = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("hangule") || attrsArray[i].equalsIgnoreCase("hangul") ) {
                	this.isHangule = true;
                    continue;
                }

                if (attrsArray[i].equalsIgnoreCase("english")){
                    isEnglish = true;
                    continue;
                }
                
                if( attrsArray[i].equalsIgnoreCase("readOnly") ) {
                	this.isReadOnly = true;
                    continue;
                }
            
                if( attrsArray[i].equalsIgnoreCase("right") ) {
                	this.isRight = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("center") ) {
                	this.isCenter = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("autoTab") ) {
                	this.isAutoTab = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("enterTab") ) {
                	this.isEnterTab = true;
                    continue;
                }

                if( attrsArray[i].equalsIgnoreCase("required") ) {
                	this.isRequired = true;
                    continue;
                }
                
                if( attrsArray[i].equalsIgnoreCase("perSize") || attrsArray[i].equalsIgnoreCase("percentSize") ) {
                	this.isPercentageSize = true;
                    continue;
                }
                
                if( attrsArray[i].toLowerCase().indexOf("desc") > -1  ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        if( indexAttr.length > 1 )
                        	descName = indexAttr[1];
                        
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild desc Attributes : " + attrsArray[i]);
                    }
                    continue;
                }
                
                if( attrsArray[i].toLowerCase().indexOf("minvalue") > -1 ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        minValue = indexAttr[1];
                        isMinValue = true;
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild tabIndex Attributes : " + attrsArray[i]);
                    }
                    continue;
                }

                if( attrsArray[i].toLowerCase().indexOf("maxvalue") > -1 ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        maxValue = indexAttr[1];
                        isMaxValue = true;
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild tabIndex Attributes : " + attrsArray[i]);
                    }
                    continue;
                }

                if( attrsArray[i].toLowerCase().indexOf("tabindex") > -1 ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        tabIndex = Integer.parseInt(indexAttr[1]);
                        isTabIndex = true;
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild tabIndex Attributes : " + attrsArray[i]);
                    }
                    continue;
                }

                if( attrsArray[i].toLowerCase().indexOf("class") > -1 ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        className = indexAttr[1];
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild class Attributes : " + attrsArray[i]);
                    }
                    continue;
                }

                if( attrsArray[i].toLowerCase().indexOf("readonly") > -1 ) {
                    try {

                        String[] indexAttr = getTokenArray(attrsArray[i].trim(), "=");
                        isReadOnly = true;
                        if( indexAttr.length > 1 )
                        	this.readOnlyColorTemp = indexAttr[1];
                    }
                    catch(Exception e) {
                        WAFLogger.error(this.getClass().getName() + " --> InputText() : " + e.getMessage());
                        WAFLogger.error("Invaild readOnly Attributes : " + attrsArray[i]);
                    }
                    continue;
                }
            }
        }
    }

    private String getInputTag() {

        // Event 처리 함수 모음 변수
        String onKeyUpEvent = "";
        String onKeyPressEvent = "";
        String onFocusEvent = "";
        String onBlurEvent = "";


        String attrsSytle = "";

        if( isRequired ) {
            attrsSytle += requiredStyle;
        }

        if(isNumber || isFloat || isMinus || isDate || isDate || isTime || isTel) {                       
            attrsSytle += numStyle;
        }
        else  {
        
            if( isHangule ) {
                attrsSytle += hanguleStyle;
            }
            else if (isEnglish) {
                attrsSytle += numStyle;
            }
            else {
                attrsSytle += englishStyle;
            }      
        }

        if( isRight ) {
            attrsSytle += rightStyle;
        }

        if( isCenter ) {
            attrsSytle += centerStyle;
        }

        if( isReadOnly ) {
            attrsSytle += readOnlyStyle + this.readOnlyColorTemp + ";";
        }

        String tag = "";
        tag += "<INPUT type=\"" + ((isPassword ? "password" : "text")) + "\" "
             + "name=\"" + this.name + "\" "
             + "id=\"" + this.name + "\" "
             + "value=\"" + this.value + "\" "
             + "maxlength=\"" + this.maxLength + "\" "
             + "class=\"" + className + "\" ";

        if( !this.isPercentageSize ) {
        	tag += "size=\"" + this.size + "\" ";
        }
        else {
        	attrsSytle += "width:" + this.size + "%;";
        }
        
        tag += "style=\"" + attrsSytle + "\" ";


        if( isTabIndex ) {
            tag += "tabIndex='" + tabIndex + "' ";
        }

        // 읽기전용 처리
        if( isReadOnly ) {
            tag += " readOnly ";
        }

        if( isMinValue ) {
            tag += "minvalue='" + minValue + "' ";
        }

        if( isMaxValue ) {
            tag += "maxvalue='" + maxValue + "' ";
        }


        // 입력 Event 처리

        if( isMinValue || isMaxValue ) {

            onBlurEvent += minMaxBlurEvent;
        }
        
        if( isFloat ) {
        	if (isMinus){
        		onKeyUpEvent += floatMinusKeyUpEvent;
        		onKeyPressEvent += floatMinusKeyPressEvent;
        	}
            else{
            	onKeyUpEvent += floatKeyUpEvent;
				onKeyPressEvent += floatKeyPressEvent;
            }
        }
		else if( isNumber) {
			if (isMinus){
				onKeyUpEvent += numberMinusKeyUpEvent;
				onKeyPressEvent += numberMinusKeyPressEvent;
			}else{
				onKeyUpEvent += numberKeyUpEvent;
				onKeyPressEvent += numberKeyPressEvent;
			}
		}
        else if( isDate || isTime ) {
        	onKeyUpEvent += numberKeyUpEvent;
            onKeyPressEvent += numberKeyPressEvent;
        }
        else if( isID ) {
            onKeyPressEvent += idKeyPressEvent;
        }
        else if( isTel ) {
            onKeyPressEvent += telKeyPressEvent;
        }
        else if(isEnglish) {
	        onKeyPressEvent += englishKeyPressEvent;
	    }
        
        if( isAutoTab ) {
            onKeyUpEvent += autoTabKeyUpEvent;
        }
        if( isEnterTab ){
            onKeyUpEvent += enterTabKeyUpEvent;
        }
        

        // Mask Event 처리
        if( this.mask.equalsIgnoreCase("Number") || this.mask.equalsIgnoreCase("Float") ) {
			onFocusEvent += numberFloatMaskFocusEvent; 
            onBlurEvent  += numberFloatMaskBlurEvent;
        }

        if( this.mask.equalsIgnoreCase("Date") ) {
            onFocusEvent += dateMaskFocusEvent;
            onBlurEvent  += dateMaskBlurEvent;
        }

        if( this.mask.equalsIgnoreCase("Time") ) {
            onFocusEvent += timeMaskFocusEvent;
            onBlurEvent  += timeMaskBlurEvent;
        }

        // 본 처리는 맨 마지막에 해야 함.
        if( isNumber || isFloat || isDate || isTime ) {

            onFocusEvent += " this.select();";
        }

        if( !onKeyUpEvent.equals("") ) {
            tag += " onKeyUp=\"JavaScript:" + onKeyUpEvent + "\" ";
        }

        if( !onKeyPressEvent.equals("") ) {
            tag += " onKeyPress=\"JavaScript:" + onKeyPressEvent + "\" ";
        }

        if( !onFocusEvent.equals("") ) {
            tag += " onFocus=\"JavaScript:" + onFocusEvent + "\" ";
        }

        if( !onBlurEvent.equals("") ) {
            tag += " onBlur=\"JavaScript:" + onBlurEvent + "\" ";
        }

        // 기타 속성 처리 
        if( isRequired ) {
            etcAttrs += " required='true'";
        }

        if( !"".equals(descName) ) {
            etcAttrs += " desc='" + descName + "'";
        }
        
        if( !this.etcAttrs.equals("") )
            tag += " " + this.etcAttrs;

        return tag + ">";
    }

    /**
     * 문장을 분리해서 String Array로 리턴(미사용)
	 * @param str
	 * @param strDelim 분리문자
	 * @return
	 */
	private static String[] getTokenArray(String str, String strDelim) {
        if( str == null || str.length() == 0 )
            return null;

        StringTokenizer st = new StringTokenizer(str, strDelim);

        String[] arrToken = new String[st.countTokens()];
        for( int i = 0 ; i < arrToken.length ; i++ )
            arrToken[i] = st.nextToken().trim();

        return arrToken;
    }

    private static String getInDeptCD(RowSet rowset) {

        StringBuffer inDeptCD = new StringBuffer();
        
        if ( rowset.size() > 0) {
            inDeptCD.append("'") ;
            for(int i=0; i<rowset.size(); i++) {
                inDeptCD.append( rowset.getRow(i).get("IN_DEPT_CD"));
                if ( i != rowset.size() -1) {
                    inDeptCD.append(",") ;
                }
            }
            inDeptCD.append("'") ;                              
        }else {
            return "" ;     
        }
        return inDeptCD.toString();
    }





    /** 현장코드 처리 (현장용)
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    public static String getSiteCode(String codeName, String siteName, ValueObject user) {

        return getSiteCode(codeName, siteName,user, false);
    }

    /** 통합현장코드 처리 (통합현장용)
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    public static String getUnionSiteCode(String codeName, String siteName, ValueObject user) {

        return getUnionSiteCode(codeName, siteName,user, false);
    }


    /** 현장코드 처리 , 현장명 크기 지정용 (현장용)
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    public static String getSiteCodeFreeSize(String codeName, String siteName, ValueObject user, int deptNameSize) {

        
        return getSiteCodeFreeSize(codeName, siteName,user, deptNameSize, false);
    }


    /** 현장코드 처리 ( 현장용, TD생성구분)
     * @param codeName
     * @param siteName
     * @param user
     * @param isTD
     * @return
     */
    public static String getSiteCode(String codeName, String siteName, ValueObject user, int isTD) {

        return getSiteCode(codeName, siteName, user, isTD==0 ? false:true);
    }


    /** 통합현장코드 처리 ( 통합현장용, TD생성구분)
     * @param codeName
     * @param siteName
     * @param user
     * @param isTD
     * @return
     */
    public static String getUnionSiteCode(String codeName, String siteName, ValueObject user, int isTD) {

        return getUnionSiteCode(codeName, siteName, user, isTD==0 ? false:true);
    }


    /** 현장코드 처리 (본사용, IN_DEPT_CD_SQL 사용 : 최종)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @return
     */
    public static String getSiteCode(String codeName, String siteName, String codeVal,  String siteVal) {
 
        return getSiteCode(codeName,siteName, codeVal, siteVal, false,1);
    }

    /** 
     * 현장코드 처리 (본사용, IN_DEPT_CD_SQL 사용 : 최종2)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @return
     */
    public static String getSiteCode2(String codeName, String siteName, String codeVal,  String siteVal) {
 
        return getSiteCode2(codeName,siteName, codeVal, siteVal, false,1);
    }

    /** 
     * 부서 검색(건축 플랜트에서 공공영업팀 데이터를 조회할 수 있도록 한 것)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @return
     */
    public static String getSiteCode3(String codeName, String siteName, String codeVal,  String siteVal) {
 
        return getSiteCode3(codeName,siteName, codeVal, siteVal, false,1);
    }

    
    /** 통합현장코드 처리 (본사용, IN_DEPT_CD_SQL 사용 : 최종)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @return
     */
    public static String getUnionSiteCode(String codeName, String siteName, String codeVal,  String siteVal) {
 
        return getUnionSiteCode(codeName,siteName, codeVal, siteVal, false,1);
    }


    /** 현장코드 처리 (본사용, IN_DEPT_CD_SQL 미사용 : 최종)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @return
     */
    public static String getAllSiteCode(String codeName, String siteName, String codeVal,  String siteVal) {
 
        return getSiteCode(codeName,siteName, codeVal, siteVal, false,0);
    }



    /** 현장코드 처리 ( 본사용, TD생성구분, 최종안)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isTD
     * @return
     */
    public static String getSiteCode(String codeName, String siteName, String codeVal, String siteVal, int isTD) {
        
        return getSiteCode(codeName, siteName, codeVal, siteVal, isTD==0 ? false:true,1);
    }



    /** 통합현장코드 처리 ( 본사용, TD생성구분, 최종안)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isTD
     * @return
     */
    public static String getUnionSiteCode(String codeName, String siteName, String codeVal, String siteVal, int isTD) {
        
        return getUnionSiteCode(codeName, siteName, codeVal, siteVal, isTD==0 ? false:true,1);
    }






    /** 현장코드 처리, 현장정보 강제 설정 ( 현장용 프로그램에서 사용 ) : 
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    private static String getSiteCode(String codeName,String siteName, ValueObject user,  boolean isMakeTD) {

        StringBuffer strBuf = new StringBuffer();
        
        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, user.get("SITE_CODE"), 10, 10, "readOnly,required") + " \n" );
        strBuf.append(get(siteName, user.get("SITE_NAME"), 24, 30, "readOnly,required") + " \n" );
//        if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
        //2005-01-03
		if(!user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") ) {

            /*
             * 검색 버튼 없음 
             */
                
        }else {
            
            strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName+ "','" + siteName + "')\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:hand;'>");
        }
        
        strBuf.append(isMakeTD ? getEndInfo():"");


        return strBuf.toString();
    }

    /** 통합현장코드 처리, 통합현장정보 강제 설정 ( 현장용 프로그램에서 사용 ) : 
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    private static String getUnionSiteCode(String codeName,String siteName, ValueObject user,  boolean isMakeTD) {

        StringBuffer strBuf = new StringBuffer();
        
        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, user.get("SITE_CODE"), 10, 10, "readOnly,required") + " \n" );
        strBuf.append(get(siteName, user.get("SITE_NAME"), 24, 30, "readOnly,required") + " \n" );
        //WAFLogger.debug("dept_"+user.get("dept_cd"));
        if ( user.get("DEPT_CD").substring(0,2).equals("62") && !user.get("DEPT_CD").substring(8,10).equals("00") ) {
            /*
             * 검색 버튼 없음 
             */
                
        }else {
            
            strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchUnionSpotSite('" + codeName+ "','" + siteName + "')\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:hand;'>");
        }
        
        strBuf.append(isMakeTD ? getEndInfo():"");


        return strBuf.toString();
    }


    /** 현장코드 처리, 현장정보 강제 설정, 현장명 크기 지정용 ( 현장용 프로그램에서 사용 ) : 
     * @param codeName
     * @param siteName
     * @param user
     * @return
     */
    private static String getSiteCodeFreeSize(String codeName,String siteName, ValueObject user, int deptNameSize, boolean isMakeTD) {

        StringBuffer strBuf = new StringBuffer();
        
        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, user.get("SITE_CODE"), 10, 10, "readOnly,required") + " \n" );
        strBuf.append(get(siteName, user.get("SITE_NAME"), deptNameSize, 30, "readOnly,required") + " \n" );
        //WAFLogger.debug("dept_"+user.get("dept_cd"));
        //if ( user.get("DEPT_CD").substring(0,2).equals("62") && !user.get("DEPT_CD").substring(8,10).equals("00") ) {

        //파견자는 파견부서만
        //겸직자는 겸직 현장선택가능하게 수정
        //2004.12.20
        if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
            /*
             * 검색 버튼 없음 
             */
                
        }else {
            
            strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName+ "','" + siteName + "')\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:pointer;'>");
        }
        
        strBuf.append(isMakeTD ? getEndInfo():"");


        return strBuf.toString();
    }





    /**
     * 현장정보 검색용 ( 본사용 프로그램에서 사용 : 최종안)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isMakeTD
     * @return
     */
    private static String getSiteCode(String codeName,String siteName, String codeVal,  String siteVal, boolean isMakeTD, int inDeptCD ) {
        
        StringBuffer strBuf = new StringBuffer();


        	strBuf.append(isMakeTD ? getStartInfo("Site"):"");       

	        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly") + " \n" );
	        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly") + " \n" );
            
	        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName + "','" + siteName + "','"+ inDeptCD +"');\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:pointer;'>");
	        
	        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }

    /**
     * 현장정보 검색용 ( 본사용 프로그램에서 사용 : 최종안2)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isMakeTD
     * @return
     */
    private static String getSiteCode2(String codeName,String siteName, String codeVal,  String siteVal, boolean isMakeTD, int inDeptCD ) {
        
        StringBuffer strBuf = new StringBuffer();


        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly") + " \n" );
        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly") + " \n" );
            
        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite2('" + codeName + "','" + siteName + "','"+ inDeptCD +"');\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:pointer;'>");
        
        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }

    /**
     * 부서 검색(건축 플랜트에서 공공영업팀 데이터를 조회할 수 있도록 한 것)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isMakeTD
     * @return
     */
    private static String getSiteCode3(String codeName,String siteName, String codeVal,  String siteVal, boolean isMakeTD, int inDeptCD ) {
        
        StringBuffer strBuf = new StringBuffer();


        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly1") + " \n" );
        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly1") + " \n" );
            
        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite3('" + codeName + "','" + siteName + "','"+ inDeptCD +"');\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:pointer;'>");
        
        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }
    

    /**
     * 통합현장정보 검색용 ( 본사용 프로그램에서 사용 : 최종안)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isMakeTD
     * @return
     */
    private static String getUnionSiteCode(String codeName,String siteName, String codeVal,  String siteVal, boolean isMakeTD, int inDeptCD ) {
        
        StringBuffer strBuf = new StringBuffer();


        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly") + " \n" );
        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly") + " \n" );
            
        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchUnionSpotSite('" + codeName + "','" + siteName + "','"+ inDeptCD +"');\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:pointer;'>");
        
        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }



    /** 기본 테이블 레이아웃 정보 생성
     * @param info
     * @return
     */
    private static String getStartInfo(String info) {
        StringBuffer strBuf = new StringBuffer();
        strBuf.append("<TD class=search_table_title>" + " \n");
        strBuf.append("<IMG src=/img/button/bullet_01.gif>" + " \n");
        strBuf.append(info + " \n");
        strBuf.append("</TD>" + " \n");
        strBuf.append("<TD class=search_table_data>&nbsp;" + " \n");
        return strBuf.toString();
    }

    private static String getEndInfo() {
        return "</TD>" + " \n";
    }
    
    
    
    /**
     * 2003-08-13 21:18:31 by hanajava
     * 현장찾기 INPUT Tag html을 생성한다.
     * 부서코드로 현장찾기 아이콘을 보여줄지 자동체크해준다.
     * @param codeName
     * @param siteName
     * @param user
     * @param js
     * @return
     */
   
	//현장선택 : 최종으로 현장 사용함 2005-01-14
	public static String getSiteCode(String codeName, String siteName, String js, ValueObject user){

		return getSiteCode(codeName, siteName, js, user, null, null);
    }
    
	/*
	 * codeVal, siteVal 넘겨받는 메소드 추가. 2007.08.07 hsj
	 */
	public static String getSiteCode(String codeName, String siteName, String js, ValueObject user, String sCodeVal, String sSiteVal){
		
		String sUserSelCodeVal = "";
		String sUserSelSiteVal = "";
		
		// codeVal 기준으로 비교한다. siteval 은 의미없음.
		if(sCodeVal == null || sCodeVal.equals(""))	{
			sUserSelCodeVal = user.get("DEPT_CD");
			sUserSelSiteVal = user.get("DEPT_NM");
		}  else {
			sUserSelCodeVal = sCodeVal;
			sUserSelSiteVal = getDeptNm(sCodeVal);
		}
		
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + sUserSelCodeVal + "' class='input' style='width:40px; background-color : #f0f0f0; border-color : #cbcbcb;' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + sUserSelSiteVal + "' class='input' style='width:200px; background-color : #f0f0f0; border-color : #cbcbcb;' readOnly>\n");
        //if(isShowIcon(user.get("dept_cd"))) {

        //파견자는 파견부서만
        //겸직자는 겸직 현장선택가능하게 수정
        //2004.12.20
        //if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
		//2005-01-03

				 sb.append("<IMG id='_btn_dept'  onClick=\"dlgSearchSpotDept('"+codeName+"', '"+siteName+"')" + js + "\" src='/img/buyer/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:pointer;'>");
				 sb.append("&nbsp;<IMG id='_btn_clear' onClick=\"dlgClear('"+codeName+"', '"+siteName+"')" + js + "\" src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>");
		
		return sb.toString();
	}
	
	public static String getSiteCodeNew(String codeName, String siteName, String js, ValueObject user, String sCodeVal, String sSiteVal){
		
		String sUserSelCodeVal = "";
		String sUserSelSiteVal = "";
		
		if( user.get("RIGHT_NAME").equals("SITE_CONT") && user.get("DEPT_CD").equals("") ){
			
			user.set("DEPT_CD", user.get("SITE_CODE"));
			user.set("DEPT_NM", user.get("SITE_NAME"));
			
		}
		
		// codeVal 기준으로 비교한다. siteval 은 의미없음.
		if(sCodeVal == null || sCodeVal.equals(""))	{
			sUserSelCodeVal = user.get("DEPT_CD");
			sUserSelSiteVal = user.get("DEPT_NM");
		}  else {
			sUserSelCodeVal = sCodeVal;
			sUserSelSiteVal = sSiteVal;
			
		}
		
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + sUserSelCodeVal + "' class='input' style='width:40px; background-color : #f0f0f0; border-color : #cbcbcb;' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + sUserSelSiteVal + "' class='input' style='width:200px; background-color : #f0f0f0; border-color : #cbcbcb;' readOnly>\n");
        //if(isShowIcon(user.get("dept_cd"))) {

        //파견자는 파견부서만
        //겸직자는 겸직 현장선택가능하게 수정
        //2004.12.20
        //if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
		//2005-01-03

				 sb.append("<IMG id='_btn_dept'  onClick=\"dlgSearchSpotDeptNew('"+codeName+"', '"+siteName+"')" + js + "\" src='/img/buyer/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:pointer;'>");
				 
				 if(user.get("RIGHT_NAME").equals("SITE_CONT") && user.get("ACCT_TYPE_ID").equals("2")){
					 sb.append("&nbsp;<IMG id='_btn_clear' onClick=\"dlgClearNew('"+codeName+"', '"+siteName+"')" + js + "\" src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>");
				 }else if( !user.get("RIGHT_NAME").equals("SITE_CONT") ){
					 sb.append("&nbsp;<IMG id='_btn_clear' onClick=\"dlgClearNew('"+codeName+"', '"+siteName+"')" + js + "\" src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>");
				 }
		
		return sb.toString();
	}
	
    /**
     * 현장찾기 INPUT Tag html을 생성한다.
     * 부서코드로 현장찾기 아이콘을 보여줄지 자동체크해준다.
     * @param codeName
     * @param siteName
     * @param user
     * @param js
     * @return
     */
   
	//현장선택 : 최종으로 현장 사용함 2005-01-14
	public static String getSiteCode3(String codeName, String siteName, String js, ValueObject user){
        StringBuffer sb = new StringBuffer();
        //sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "'  size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        //sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "'  size='20' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");
        
        sb.append(get(codeName, user.get("site_code"), 30, 10, "readOnly,perSize") + " \n" );
        sb.append(get(siteName, user.get("site_name"), 45, 30, "readOnly,perSize") + " \n" );
        //if(isShowIcon(user.get("dept_cd"))) {

        //파견자는 파견부서만
        //겸직자는 겸직 현장선택가능하게 수정
        //2004.12.20
        //if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
		//2005-01-03
		if(!user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") ) {

             /*
             * 검색 버튼 없음 
             */			
        } else {

				 sb.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite3('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:hand;'>");
		
		}
        
		return sb.toString();
    }
	
    /**
     * 2003-08-13 21:18:31 by hanajava
     * 현장찾기 INPUT Tag html을 생성한다.
     * 부서코드로 현장찾기 아이콘을 보여줄지 자동체크해준다.
     * @param codeName
     * @param siteName
     * @param user
     * @param js
     * @return
     */
    public static String getUnionSiteCode(String codeName, String siteName, String js, ValueObject user){
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "' size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "' size='24' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");
        if(isShowIcon(user.get("dept_cd"))) {

            sb.append("<IMG id='search_spot_button' onClick=\"dlgSearchUnionSpotSite('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='통합현장찾기' style='cursor:hand;'>");
        }
        return sb.toString();
    }

    /**
     * 
     * 현장찾기 INPUT Tag html을 생성한다.
     * 부서코드로 현장찾기 아이콘을 보여줄지 자동체크해준다.
     * @param codeName
     * @param siteName
     * @param js
     * @param user
     * @param deptNameSize
     * @return
     */
    public static String getSiteCodeFreeSize(String codeName, String siteName, String js, ValueObject user, int deptNameSize){
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "' size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "' size='"+deptNameSize+"' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");
        //if(isShowIcon(user.get("dept_cd"))) {
        
        //파견자는 파견부서만
        //겸직자는 겸직 현장선택가능하게 수정
        //2004.12.20
        //if(isShowIcon(user.get("dept_cd")) || (user.get("T101PSOSO").equals("") && !user.get("T101DSO1").equals(""))) {
        if(!user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") ) {
		     /*
             * 검색 버튼 없음 
             */			
        } else {

			sb.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:hand;'>");
		
		}
                   
        return sb.toString();		
    }
    
    /**
     * 2003-08-13 21:18:31 by hanajava
     * 부서코드로 현장찾기 아이콘을 보여줄지 여부를 확인한다.
     * 62:현장, 69:본사현장, 63:해외현장, 68:하자보수
     * @param deptCd
     * @return boolean
     */
    private static boolean isShowIcon(String deptCd){
        boolean flag = true;
        try {
            //List list = Arrays.asList(new String[]{"62", "63", "68", "69"});
            String prefix = deptCd.substring(0,2);
            String suffix = deptCd.substring(8,10);
            //통합현장이면 true
            if("62".equals(prefix) && !"00".equals(suffix) ) {
                flag = false;
            }
        } catch(Exception e){
            WAFLogger.error("[Exception]InputText.isShowIcon()...\n"+e);
        }
        return flag;
    }
    
    
	//발주처
	public static String getVendorCode(String codeName, String siteName, String codeVal, String siteVal, String js){
        StringBuffer sb = new StringBuffer();
        
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + codeVal + "' size='10' maxsize='10' class='input' style='BACKGROUND-COLOR : #dedede;width:26%;' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + siteVal + "' size='24' maxsize='24' class='input' style='BACKGROUND-COLOR : #dedede;width:55%;' readOnly>\n");

        sb.append("<IMG id='search_spot_button' onClick=\"dlgSearchVendor('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[발주처찾기]' style='cursor:hand;'>");
		
		return sb.toString();
    }    

/*
    public static String getStartInfoX(String info) {
        StringBuffer strBuf = new StringBuffer();
        
        strBuf.append("<TD width=\"57\" class=\"LeftSpace\"><IMG src=\"/img/temp/bullet_01.gif\">"+info+"</TD>" + " \n");
        strBuf.append("<TD width=\"5\" bgcolor=\"#fefefe\"></TD>" + " \n");
        strBuf.append("<TD width=\"295\" bgcolor=\"#fefefe\">" + " \n");
        
        return strBuf.toString();
    }
*/

/***********************************************************************************************************************************************************/


    /** 현장코드 처리 (본사용, IN_DEPT_CD RowSet 사용)
     */
    public static String getSiteCode(String codeName, String siteName, String codeVal,  String siteVal, RowSet inDeptCDs) {
    
        String inDeptCD = "" ;
            
        inDeptCD = getInDeptCD(inDeptCDs);  
    
        return getSiteCode(codeName,siteName, codeVal, siteVal, inDeptCD, false);
    }



    /** 현장코드 처리 (본사용, IN_DEPT_CD RowSet 사용)
     */
    public static String getUnionSiteCode(String codeName, String siteName, String codeVal,  String siteVal, RowSet inDeptCDs) {
    
        String inDeptCD = "" ;
            
        inDeptCD = getInDeptCD(inDeptCDs);  
    
        return getUnionSiteCode(codeName,siteName, codeVal, siteVal, inDeptCD, false);
    }

    
    /** 현장코드 처리 ( 본사용, TD생성구분)
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param isTD
     * @return
     */
    public static String getSiteCode(String codeName, String siteName, String codeVal, String siteVal, RowSet inDeptCDs, int isTD) {
            
        String inDeptCD = "" ;
            
        inDeptCD = getInDeptCD(inDeptCDs);  
    
        return getSiteCode(codeName, siteName, codeVal, siteVal, inDeptCD, isTD==0 ? false:true);
    }


    /** 현장코드 처리 (본사용)
     * @param siteName
     * @param siteVal
     * @return
     */
    public static String getSiteCode(String siteName, String siteVal ) { 

        return getSiteCode(siteName, siteVal, false);
    }

    /** 통합현장코드 처리 (본사용)
     * @param siteName
     * @param siteVal
     * @return
     */
    public static String getUnionSiteCode(String siteName, String siteVal ) { 

        return getUnionSiteCode(siteName, siteVal, false);
    }

    /** 현장코드 처리 ( 본사용, TD생성구분 )
     * @param siteName
     * @param siteVal
     * @param isTD
     * @return
     */
    public static String getSiteCode(String siteName, String siteVal, int isTD) {

        return getSiteCode(siteName, siteVal, isTD==0 ? false:true);
    }

    /** 현장코드 처리 ( 본사용, TD생성구분 )
     * @param siteName
     * @param siteVal
     * @param isTD
     * @return
     */
    public static String getUnionSiteCode(String siteName, String siteVal, int isTD) {

        return getUnionSiteCode(siteName, siteVal, isTD==0 ? false:true);
    }
    


    /**
     * 현장정보 검색용 ( 본사용 프로그램에서 사용 )
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param inDeptCD
     * @param isMakeTD
     * @return
     */
    private static String getSiteCode(String codeName,String siteName, String codeVal,  String siteVal,String inDeptCD,  boolean isMakeTD ) {
        
        StringBuffer strBuf = new StringBuffer();


        strBuf.append(isMakeTD ? getStartInfo("현 장"):"");       

        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly") + " \n" );
        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly") + " \n" );
            
        strBuf.append("<A href=> ");
        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName + "','" + siteName + "'," + inDeptCD + ")\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:hand;'></A> ");
        
        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }





    /**
     * 통합현장정보 검색용 ( 본사용 프로그램에서 사용 )
     * @param codeName
     * @param siteName
     * @param codeVal
     * @param siteVal
     * @param inDeptCD
     * @param isMakeTD
     * @return
     */
    private static String getUnionSiteCode(String codeName,String siteName, String codeVal,  String siteVal,String inDeptCD,  boolean isMakeTD ) {
        
        StringBuffer strBuf = new StringBuffer();


        strBuf.append(isMakeTD ? getStartInfo("통합현장"):"");       

        strBuf.append(get(codeName, codeVal, 10, 10, "readOnly") + " \n" );
        strBuf.append(get(siteName, siteVal, 24, 30, "readOnly") + " \n" );
            
        strBuf.append("<A href=> ");
        strBuf.append("<IMG id='search_spot_button' onClick=\"dlgSearchUnionSpotSite('" + codeName + "','" + siteName + "'," + inDeptCD + ")\" src=\"/img/button/bt_search_right.gif\" border=\"0\" align=\"absmiddle\" style='cursor:hand;'></A> ");
        
        strBuf.append(isMakeTD ?getEndInfo():"");

        return strBuf.toString();
    }




    /** 현장정보 검색용 ( 본사용 프로그램, 스트링입력용 : 사용 보류 )
     * @param siteName
     * @param siteVal
     * @return
     */
    private static String getSiteCode(String siteName, String siteVal, boolean isMakeTD ) {
        
        StringBuffer strBuf = new StringBuffer();

        strBuf.append(isMakeTD ? getStartInfo("현장명&nbsp;"):"");     

        strBuf.append(get(siteName, siteVal, 24, 30, "") + " \n" );

        strBuf.append(isMakeTD ? getEndInfo():"");
        
        return strBuf.toString();
    }



    /** 통합현장정보 검색용 ( 본사용 프로그램, 스트링입력용 : 사용 보류 )
     * @param siteName
     * @param siteVal
     * @return
     */
    private static String getUnionSiteCode(String siteName, String siteVal, boolean isMakeTD ) {
        
        StringBuffer strBuf = new StringBuffer();

        strBuf.append(isMakeTD ? getStartInfo("통합현장명&nbsp;"):"");     

        strBuf.append(get(siteName, siteVal, 24, 30, "") + " \n" );

        strBuf.append(isMakeTD ? getEndInfo():"");
        
        return strBuf.toString();
    }
    
    /**
     * 2006-03-29 21:18:31 by hanajava
     * 분양현장찾기 INPUT Tag html을 생성한다.
     * 부서코드로 분양현장찾기 아이콘을 보여줄지 자동체크해준다.
     * @param codeName
     * @param siteName
     * @param user
     * @param js
     * @return
     */
   
    //현장선택
    public static String getHousSiteCode(String codeName, String siteName, String js, ValueObject user){
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "' size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "' size='24' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");
        
        // 박선우 수정
        
        //if(!user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") ) {
        if(!user.get("dept_cd").equals("") && !user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") && !(user.getInt("SITE_CNT",0) > 1  || (user.get("ACCT_TYPE_CODE").indexOf("ADMIN") > 0))) {

             /*
             * 검색 버튼 없음 
             */
        } else {

            sb.append("<IMG id='search_spot_button' onClick=\"HOUSdlgSearchSpotSite('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[분양현장찾기]' style='cursor:hand;'>");

        }
        
        return sb.toString();
    }
    
    //  현장선택 검색 버튼 없음
    public static String getHousSiteCode(String codeName, String siteName, ValueObject user){
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "' size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "' size='24' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");

        return sb.toString();
    }
    
	/**
	 * 예산편성에서 사용되는 컨트롤
	 * 
	 * @param codeName	String
	 * @param siteName	String
	 * @param js		String	
	 * @param user		ValueObject
	 * @return String
	 */
	public static String getSiteCode_for_BUD(String codeName, String siteName, String js, ValueObject user) {
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + user.get("site_code") + "' size='10' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + user.get("site_name") + "' size='24' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");

        
		if(!user.get("dept_cd").equals("6118002000") 
				&& !user.get("dept_cd").equals("6148004000") && !user.get("dept_cd").equals("6153005000") && !user.get("dept_cd").equals("6156005000")
				&& !user.get("dept_cd").equals("6137003000")) {

             /*
             * 검색 버튼 없음 
             */			
        } else {	// 기획팀, 토목환경지원팀, 건축지원팀, 플랜트지원팀, 인력팀

				 sb.append("<IMG id='search_spot_button' onClick=\"dlgSearchSpotSite('" + codeName + "', '" + siteName + "');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:hand;'>");
		
		}
        
		return sb.toString();
    }
	
	/**
	 * 자재관리 현장찾기 INPUT Tag html을 생성한다. by pure
	 * 부서코드로 현장찾기 아이콘을 보여줄지 자동체크해준다.
	 * @param codeName
	 * @param siteName
	 * @param user
	 * @param js
	 * @return
	 */
	public static String getPlantSiteCode(String codeName, String siteName, String js, ValueObject user){
		
		return getPlantSiteCode(codeName, siteName, js, user, null, null, null);
    }
	public static String getPlantSiteCode(String codeName, String siteName, String js, ValueObject user, String DefaultMaterial){
		
		return getPlantSiteCode(codeName, siteName, js, user, null, null, DefaultMaterial);
	}
    
	/*
	 * 자재관리 by pure 
	 */
	public static String getPlantSiteCode(String codeName, String siteName, String js, ValueObject user, String sCodeVal, String sSiteVal, String DefaultMaterial){
		
		String projectcd 	= "";
		String projectnm 	= "";
		String projectid 	= "";
		String idName		= "projectid";
		String windowFeatures = "toolbar=no,directories=no,status=no,scrollbars=no,resize=no,menubar=no";
		
		if(sCodeVal == null || sCodeVal.equals(""))	{
			projectid = user.get("PROJECT_ID");
			projectcd = user.get("PROJECT_CD");
			projectnm = user.get("PROJECT_NM");
		}  else {
			projectcd = sCodeVal;
			projectnm = sSiteVal;
		}
		
        StringBuffer sb = new StringBuffer();
        sb.append("<INPUT type='text' name='" + codeName + "' value='" + projectcd + "' size='12' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='text' name='" + siteName + "' value='" + projectnm + "' size='24' maxsize='24' class='input' style='background-color:#eeeeee' readOnly>\n");
        sb.append("<INPUT type='hidden' name='" + idName + "' value='" + projectid + "' size='12' maxsize='10' class='input' style='background-color:#eeeeee' readOnly>\n");

//		if(!user.get("dept_cd").substring(0,2).equals("61") && user.get("CHECK_CNT1").equals("N") ) {
//         /*
//         * 검색 버튼 없음 
//         */			
//        } else {
//				 sb.append("<IMG id='search_spot_button' onClick=\"popProjectList('" + codeName + "', '" + siteName + "', '"+idName+"', '"+DefaultMaterial+"');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[Project List Search]' style='cursor:hand;'>");
//		
//		}
		sb.append("<IMG id='search_spot_button' onClick=\"popProjectList('" + codeName + "', '" + siteName + "', '"+idName+"', '"+DefaultMaterial+"');" + js + "\" src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[Project List Search]' style='cursor:hand;'>");
        
		return sb.toString();
	}
	
	private static String getDeptNm(String dept_cd) {

        Search search = new SearchImpl();
        RowSet rowSet = null;
        String sqlstr = "";
        String returnValue = "";
        
        try {
             sqlstr = "     SELECT 	DEPT_NM				\n";
			 sqlstr += "		  FROM ACZ10100V					\n";
			 sqlstr += "		  WHERE DEPT_CD = ?				\n";
			           
            
            search.setStatement(sqlstr);
            search.addParameter(dept_cd);
            
            rowSet = search.execute();
            if(rowSet.size() > 0) {
            	returnValue = rowSet.getRow(0).get("DEPT_NM");
            }
        }
        catch(Exception e) {
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
        }
        return returnValue;
    }
}