<%--
  - FileName   : UserList.jsp
  - Author(s)  : Joung Kyu Park
  - Date       : 2007.05.16
  - Copyright  : Copyright (c) 2002-2007 www.hwenc.com, Inc.
  -
  - Description: 사용자 등록
  --%>
  


<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    String event = storage.getEvent();
    
    
    RowSet statusComboList = storage.getRowSet("statusComboList"); //상태 ComboList Data
    
    //검색조건 작성일
	String  initSearchDateStart = params.get("searchDateStart");
    String  initSearchDateEnd = params.get("searchDateEnd");
    
  //검색조건 현장 설정
  	String initSearchDeptCd = params.get("searchDeptCd");
  	String initSearchDeptNm = params.get("searchDeptNm");
  	
  	String initStatusCd = params.get("searchStatusCd");
    if(initStatusCd == null || initStatusCd == ""){
    	initStatusCd = "";
    }
   
    String  searchBuildName = params.get("searchBuildName");
%>
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1;
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	function _onReady(){
		/**
		 *	IBSheet object initialize
		 */
		gridInit(sheet1);
		
	
		/**
		 *	Application Initialize
		 */
		jQuery("#btnSearch").click(function() {
		    
		    if($("#searchDateStart").val() != "" && $("#searchDateEnd").val() == "")
	        {
		        alert("검토완료 시작일을 입력해 주시기 비랍니다.");
	            return;
	        }
		    else if($("#searchDateStart").val() == "" && $("#searchDateEnd").val() != "")
	        {
		        alert("검토완료 종료일을 입력해 주시기 비랍니다.");
	            return;
	        }
		    
		    if($("#searchDateStart").val() > $("#searchDateEnd").val())
	        {
		        alert("시작일이 종료일보다 클 수 없습니다..");
	            return;
	        }
			
 			jQuery("#fevent").val("GET_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/payment/purchase/VendorPrintCheckList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10000, ""); 
			 
			autoResize();
		});
		
		pageinit();
		
	}
	
	function pageinit(){
		jQuery("#btnSearch").click();
	}
	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
		    			{Header:"Status",				Type:"Status", 		SaveName:"STATUS", 							Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:"현장명",				Type:"Text", 			SaveName:"DEPT_NAME",						Width:100, 	Align:"Left"},
		    			{Header:"현장코드",			Type:"Text", 			SaveName:"DEPT_CD", 							Width:0, 	Align:"Left", Hidden:"True"},
// 		    			{Header:"계약번호",			Type:"Text", 			SaveName:"ORD_DOC_NO", 					Width:110, 	Align:"Center"},
		    			{Header:"☞계약명",			Type:"Text", 			SaveName:"CST_DOC_NAME", 				Width:150, 	Align:"Left"},
		    			{Header:"업체명",				Type:"Text", 			SaveName:"MEMBER_NAME", 					Width:150, 	Align:"Left"},
		    			{Header:"VP 검토항목",		Type:"Text", 			SaveName:"VP_DESC", 							Width:150, 	Align:"Left"},
		    			{Header:"검토완료일",		Type:"Text", 			SaveName:"VP_END_DY", 						Width:100, 	Align:"Center"},
		    			{Header:"지급구분코드",		Type:"Text", 			SaveName:"DEPOSIT_CD", 						Width:100, 	Align:"Left", Hidden:"True"},
		    			{Header:"지급구분",			Type:"Text", 			SaveName:"DEPOSIT_NM", 					Width:100, 	Align:"Center"},
		    			{Header:"지급차수",			Type:"Text", 			SaveName:"DEPOSIT_SEQ", 					Width:100, 	Align:"Center"},
		    			{Header:"통화",				Type:"Text", 			SaveName:"CURRENCY_GB", 					Width:100, 	Align:"Center"},
		    			{Header:"금회 기성고",		Type:"Int", 				SaveName:"CUR_ACMP_APPLYAMT", 		Width:100, 	Align:"Right", Format:"#,##0"},
		    			{Header:"상태코드",			Type:"Text", 			SaveName:"VP_STATUS", 						Width:100, 	Align:"Center", Hidden:"True"},
		    			{Header:"상태",				Type:"Text", 			SaveName:"VP_STATUS_NM", 				Width:100, 	Align:"Center"},
		    			{Header:"PUR_CONT_ID",	Type:"Text", 			SaveName:"PUR_CONT_ID", 					Width:100, 	Align:"Center", Hidden:"True"},
		    			{Header:"PAYREQ_ID",		Type:"Text", 			SaveName:"PAYREQ_ID", 						Width:100, 	Align:"Center", Hidden:"True"}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		
		sheetName.SetDataLinkMouse("CST_DOC_NAME", 1);
		sheetName.SetColFontColor("CST_DOC_NAME", "#0000ff");
		sheetName.SetActionMenu("ExcelDown");
		setGridSize();
	}

	function sheet1_OnSelectMenu(Text, Code) {
		// text 또는 code값으로 Action수행
		switch(Text) {
			case "ExcelDown":
			sheetExcelDown(sheet1,$('li').html());
			break;
		}
	}
	
	
	//달력팝업	
	function calendar(thisDayObj){
		dlgCalendar(thisDayObj);
	}	
	
	
	
	
	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + 24;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   
		
		
		sheet1.SetSheetHeight(iframeHeight); 
	}	
	
	
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Save End(IBSheet 데이터 저장 CallBack)
	 */
	function sheet1_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	alert("저장 성공");
	    } else {
	    	alert(msg);
        }
	}
	
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 //masterSheetRow = Row;
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
	     
	     var saveName = sheet1.ColSaveName(Col);
	     
	     if(saveName == "CST_DOC_NAME")
         {
	         	$("#fevent").val("GET_DETAIL");

	         	$("#purContId").val(sheet1.GetCellValue(Row, "PUR_CONT_ID"));
				$("#payreqId").val(sheet1.GetCellValue(Row, "PAYREQ_ID"));
	         	
		        $("#form1").attr("action", "/payment/purchase/VendorPrintCheck.screen");
				$("#form1").submit();
         }
		 
	 }

	
	//자동로그인 기능
	function f_gologin(login_id,login_pw){
		var f = document.form1;
		if('<%= user.get("ACCT_TYPE_CODE")%>' != "ADMIN"){
			dlgAlert("User who logged in as administrator only can do automatic log-in.");
			return;
		}
	
		f.login_id.value = login_id;
		f.login_pw.value = login_pw;
	
		if( !submitXmlRequest("/sign_on_check", "", document.form1) ) {
			alert("Log-in is being processed.");
		};
	
	}

	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "" ) {
				if( resultObj.getSuccess() ) {				
					var f = document.form1;   				  				
					f.action = "/main.screen";				
	    			f.target = "_parent";             			
	    			f.submit();			
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}else if( resultObj.getRequestEvent() == "GET_EHR_DATA" ) {
				if( resultObj.getSuccess() ) {
					alert("EHR Synchronize Complete");
					doSearch(document.all.sheet1);
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
	        showErrorDlg("doResult()", errorObject);
		}
	}

</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search" style="width:100%;height:100%;" action="">
	<INPUT type="hidden" name="fevent" id="fevent" value="">
	<INPUT type="hidden" name="purContId" id="purContId" value="">	<!-- 상세선택 key -->
	<INPUT type="hidden" name="payreqId" id="payreqId" value="">	<!-- 상세선택 key -->
	
   <div align="left" id="title">
    <ul>
     <li>구매_Vendor Print 검토</li>
    </ul>
  </div> 
	<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="100px">
			<col width="40%">
			<col width="100px">
			<col/>
			<col width="100px">
		</colgroup>
		<tr>
			<th>현장</th>
			<td>
				<%--<%=InputText.getSiteCode("searchDeptCd", "searchDeptNm", "", user, initSearchDeptCd, initSearchDeptNm)%> --%>
				<%=InputText.getSiteCodeNew("searchDeptCd", "searchDeptNm", "", user, initSearchDeptCd, initSearchDeptNm)%>
			</td>
			<th>계약명</th>
			<td>
				<INPUT type="text" id="searchBuildName" name="searchBuildName" value="<%=searchBuildName%>" maxlength="50" class="input" style="IME-MODE : active;width:95%;"   desc='계약명'>
			</td>			
			<td class="button" rowspan="3">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
			</td>			
		</tr>
		<tr>			
			<th>검토완료일</th>
			<td>
				<%= InputText.get("searchDateStart", initSearchDateStart, 15, 50, "Center, date, PerSize, readonly", "date", "") %>
				<a href="JavaScript:calendar('searchDateStart');"><img src="/img/buyer/button/bt_calender.gif" alt="달력" border="0" align="absmiddle" /></a>
				&nbsp;~&nbsp;
				<%= InputText.get("searchDateEnd", initSearchDateEnd, 15, 50, "Center, date, PerSize, readonly", "date", "") %>
				<a href="JavaScript:calendar('searchDateEnd');"><img src="/img/buyer/button/bt_calender.gif" alt="달력" border="0" align="absmiddle" /></a>
			</td>			
			<th>상태</th>
			<td>
				<%= HTMLMaker.getSelectTag(statusComboList, "DETAILCD", "DETAILNM", "searchStatusCd", "width:50%;height=18;", "<option value=''>--전체--</option>", initStatusCd) %>
			</td>			
		</tr>
		<TR>
			<TH>업체명</TH>
			<TD colspan="3">
				<INPUT type="text" id="searchCorp" name="searchCorp" value="" maxlength="50" class="input" style="IME-MODE : active; width:42%;"  desc='업체명' onKeyPress="doKeyPress();">
			</TD>
   		</TR>
	</table>
	<!-- 검색조건 종료 -->
	<img src="/img/com/blank.gif" height="5px" />
<!--    <div align="right" id="bugase"> -->
<!--     	<ul> -->
<!--      		<li valign="bottom"><span style="color: red;">* 부가세별도</span></li> -->
<!--     	</ul> -->
<!--   	</div>	 -->
	<div id="sheet1_div" style="padding-top:0px; height: auto; min-height: 350px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '350px');</script>
	</div>
</FORM>