<%--
  - 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.*" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@ page import="com.udapsoft.waf.common.util.Formatter2"%>

<%@ 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();
    
    ValueObject prePayment = storage.getValueObject("prePayment");			//기본정보, 세금계산서정보, 선급금정보
    
    ValueObject filein = storage.getValueObject("PURCHASE_"+prePayment.get("PAYREQ_ID"));
    
    String digit = "0"; //(String)prePayment.get("digit");
	int intDigit = Integer.parseInt(digit);
	
// 	return_reson_area


	String status = prePayment.get("VP_STATUS");
   
%>
<script type="text/javascript">
<!--

	$(document).ready(function(){
	    
	    var status = "<%=status%>";

	    if(status == "03")	//신청대상(검토대상)
        {
	        $("#return_reson_area").css("display", "none");
	        $("#btn_confim_area").css("display", "none");
	        $("#btn_return_area").css("display", "none");
        }
	    
	    if(status == "40")	//VP심사중
        {
	        $("#return_reson_area").css("display", "none");
        }
	    
	    if(status == "50" || status == "60" )
        {
	        $("#opinion").attr("readonly", true);
	        $("#btn_save_area").css("display", "none");
	        $("#btn_confim_area").css("display", "none");
	        $("#btn_return_area").css("display", "none");
        }
	});

	$(function(){
	    
	  //첨부파일
		$("#search_spot_button").click(function(){
		    
		    var obj = $("#payreqId").val();
		    var no = "1";
		    
		    if(no == 1)
		    {
// 				viewFileListNew("PUR_VENDOR", obj, document.form1.p_AttachFile1, "Y", "payment/purchase/" + obj, null, "240");
		        viewFileListNew('PURCHASE_'+obj, "240", document.form1.p_AttachFile1, "Y", "payment/purchase/"+obj.value);
			}
		    
		});
	  
	  
	  $("#btn_list").click(function(){
	      
	      	$("#fevent").val("");
	        $("#form1").attr("action", "/payment/purchase/VendorPrintCheckList.screen");
	        $("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();	        
	      
	  });
	  
	  
	  $("#btn_return").click(function(){
	      
	      $("#fevent").val("CON_RETURN");
	      
	      	var url = "/payment/purchase/VendorPrintCheckReturnPop.screen";
			var win_id = "_returnPop";
			url += "?pop_win_id="+win_id;
			url += "&payreqId="+$("#payreqId").val();
			
			fLayerPop(win_id, url, 550,130, '', '', 'NO');
	      
	  });
	  
	$("#btn_confim").click(function(){
	    
	    var f = document.form1;
	      
	      if(confirm("승인 하시겠습니까?"))
	      {
	          $("fevent").val("SAVE_DATA");
	          $("#status").val("60");
	          
	          submitXmlRequest("/payment/purchase/VendorPrintCheck_form.screen", "SAVE_DATA", f);
          }
	      
	  });
	  
	  
	  $("#btn_save").click(function(){
	      
	      var status = "<%=prePayment.get("VP_STATUS")%>";
	      var f = document.form1;
	      
	      var VP_END_DY = jQuery("#VP_END_DY").val();
	      var VP_DESC = jQuery("#VP_DESC").val();
	      
	      if(VP_END_DY == ""){
	    	  alert("검토일자를 입력해주세요");
	    	  jQuery("#VP_END_DY").focus();
	    	  return;
	      }
	      if(VP_DESC == ""){
	    	  alert("검토항목를 입력해주세요");
	    	  jQuery("#VP_DESC").focus();
	    	  return;
	      }
	      
	      if(confirm("저장 하시겠습니까?"))
	      {
	          $("fevent").val("SAVE_DATA");
	          $("#status").val("40");
	          
	          submitXmlRequest("/payment/purchase/VendorPrintCheck_form.screen", "SAVE_DATA", f);
          }
	      
	  });
	  
	    
	});
	
	
function doResult(resultObj) 
{
	try 
	{
	    if( resultObj.getRequestEvent() == "SAVE_DATA") 
	    {
	        if($("#fevent").val() == "CON_RETURN")
            {
	            var url = "/payment/purchase/VendorPrintCheckReturnPop.screen";
				var win_id = "_returnPop";
				url += "?pop_win_id="+win_id;
				url += "&payreqId="+$("#payreqId").val();
				
				fLayerPop(win_id, url, 550,130, '', '', 'NO');
            }
	        else
            {
	            if( resultObj.getSuccess() ) 
				{
					alert("저장되었습니다.");
					document.form1.isSubmit = false;
					
					$("#fevent").val("GET_DETAIL");
					$("#form1").attr("action", "/payment/purchase/VendorPrintCheck.screen");
			        $("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
// 					$("#btn_list").click();
				}
				else 
				{
//	 				dlgErrorMsg(resultObj.getMessage);
					alert(resultObj.getValueObject().get("errMsg"));
					document.form1.isSubmit = false;
				}
            }
		}
	}
	catch(errorObject) {
        showErrorDlg("doResult()", errorObject);
	}
}

function SearchUser(NAME,CODE,DEPT_YN){
	
	CODE = "";
	NAME = "";
	GB = "PUREMP";

	var win_id = "_searchUserPopup";
	var link = "/lib/dlgSearchUserPop.screen";
	    link += "?pop_win_id="+win_id;
	    link += "&NAME="+NAME;
	    link += "&CODE="+CODE;
	    link += "&GB="+GB;
	    if(DEPT_YN == "Y")
	    	link += "&deptNameYn=purchase";
	fLayerPop(win_id, link, 700,400, '', '', 'NO');
}

function SearchUserClose(result){
	
	jQuery("#VP_CHK_EMPNO").val(result[9])//ACCT_ID
	jQuery("#VP_CHK_EMPNM").val(result[1])//이름
	jQuery("#EPART_DEPT_NAME").val(result[3])//부서
	
	setTimeout(function(){	fLayerPopClose('_searchUserPopup');},100);
}

function calendar(thisDayObj){
	dlgCalendar(thisDayObj);
}		


//-->
</script>

<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>

<form id="form1" name="form1" method="post" modular:type="search">

	<INPUT type="hidden" name="fevent" id="fevent" value="">
	<INPUT type="hidden" name="payreqId" id="payreqId" value="<%=prePayment.get("PAYREQ_ID") %>"/>	<!-- 발주계약ID -->
	<INPUT type="hidden" name="purContId" id="purContId" value="<%=prePayment.get("PUR_CONT_ID") %>"/>	<!-- 발주계약ID -->
	<INPUT type="hidden" name="subContModId" id="subContModId" value="<%=prePayment.get("PUR_CONT_MOD_ID") %>"/>
	<INPUT type="hidden" name="dept_cd" id="dept_cd" value="<%=prePayment.get("DEPT_CD") %>"/>	<!-- 현장코드 -->
	<INPUT type="hidden" name="lastDate" id="lastDate" value=""/>
	
	<!-- 리스트 검색조건 보존 시작-->
	<INPUT type='hidden' id="searchDeptCd" name="searchDeptCd" value="<%=params.get("searchDeptCd")%>"/>	<!-- 현장코드 -->
	<INPUT type='hidden' id="searchDeptNm" name="searchDeptNm" value="<%=params.get("searchDeptNm")%>"/>	<!-- 현장명 -->
	<INPUT type='hidden' id="searchBuildName" name="searchBuildName" value="<%=params.get("searchBuildName")%>"/>	<!-- 계약명 -->
	<INPUT type='hidden' id="searchDateStart" name="searchDateStart" value="<%=params.get("searchDateStart")%>"/>	<!-- 작성 시작일 -->
	<INPUT type='hidden' id="searchDateEnd" name="searchDateEnd" value="<%=params.get("searchDateEnd")%>"/>			<!-- 작성 종료일 -->
	<INPUT type='hidden' id="searchStatusCd" name="searchStatusCd" value="<%=params.get("searchStatusCd")%>"/>			<!-- 상태값 -->
	<!-- 리스트 검색조건 보존 종료-->
	
	<input type='hidden' id="status" name="status" value=""/>			<!-- 상태값 -->
	
	
	<table border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
		<tr>
			<td style="text-align: left;">
				<div align="left" id="title" style="float: left;">
					<ul>
				    	<li>Vendor Print 검토 상세(<%= prePayment.get("VP_STATUS_NM") %>)</li>
				    	<li>
				   	</ul>
				</div> 
			</td>
			<td style="text-align: right; vertical-align: bottom;">
				<span class="btnSearch center" id="btn_save_area"><a href="javascript:void(0);" id="btn_save">저장</a></span>
				<span class="btnSearch center" id="btn_confim_area"><a href="javascript:void(0);" id="btn_confim">승인</a></span>
				<span class="btnSearch center" id="btn_return_area"><a href="javascript:void(0);" id="btn_return">반려</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btn_list">목록</a></span>
			</td>
		</tr>
	</table>
	
	<div class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">계약정보</span>
		</div>
		<div class="application-location"></div>
	</div>
	
	<TABLE class="form-table">
		<colgroup>
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="*" />
		</colgroup>

		<TR height="25">
			<th style="text-align: left;">현장명</th>
			<TD><%= prePayment.get("DEPT_NAME") %></TD>
			<th style="text-align: left;">계약명</th>
			<TD><%= prePayment.get("CST_DOC_NAME") %></TD>
			<th style="text-align: left;">통화</th>
			<TD><%= prePayment.get("CURRENCY_GB") %></TD>
		</TR>
		<TR>
			<th style="text-align: left;">사업자번호</th>
			<TD><%= prePayment.get("VENDCD") %></TD>

			<th style="text-align: left;">계약업체명</th>
			<TD><%= prePayment.get("MEMBER_NAME") %></TD>

			<th style="text-align: left;">대표이사</th>
			<TD><%= prePayment.get("BOSS_NAME") %></TD>
		</TR>
		<TR>
			<th style="text-align: left;">계약기간</th>
			<TD><%= prePayment.get("ORD_START_END_DATE") %></TD>
			<th style="text-align: left;">계약금액</th>
			<TD><%= Formatter2.currency(prePayment.get("ORD_AMT"), intDigit)%> (부가세 별도)</TD>
			<th style="text-align: left;">선급금액</th>
			<TD><%= Formatter2.currency(prePayment.get("PREPAY_SUPPLY_AMT"), intDigit)%> (부가세 별도)</TD>
		</TR>
		<TR height="55">
			<th style="text-align: left;">대금지불방법</th>
			<TD colspan="5"><%=prePayment.get("DDD") %></TD>			
		</TR>
	</TABLE>
	
	<!-- 대금정보 시작 -->
	<div class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">대금정보</span>
		</div>
		<div class="application-location"></div>
	</div>
	
	<table class="form-table">
		<colgroup>
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="*" />
		</colgroup>
		
		<tr height="25">
			<th style="text-align: left;">대금구분</th>
			<td><%=prePayment.get("PAY_DIV") %></TD>
			<th style="text-align: left;">지급구분/차수</th>
			<td><%=prePayment.get("DEPOSIT_NM") %> / <%= Integer.parseInt(prePayment.get("DEPOSIT_SEQ")) %> 회차</TD>
			<th style="text-align: left;">업체신청일시</th>
			<td><%= prePayment.get("CUST_SIGN_DATE") %></TD>
		</tr>
	</table>
	
	<!--  첨부 -->
	<div class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">첨부 및 기타서류</span>
		</div>
		<div class="application-location">
		</div>
	</div>
	
	
	<table class="form-table">
		<colgroup>
			<col width="13%" />
			<col width="*" />
		</colgroup>
		
		<tr height="25">
			<th>
				첨부파일
			</th>
			<td>
				<textarea name="p_AttachFile1" id="p_AttachFile1" style="width:85%;height:80px" rows="1" class="input" readOnly><%=filein.get("PURCHASE_"+ prePayment.get("PAYREQ_ID")) %></textarea>
				<img id="search_spot_button" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:hand; vertical-align: middle; margin-bottom: 20px; cursor: pointer;'>
			</td>
		</tr>
	</table>
	
	
	<!-- Vendor Print -->
	<div class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">Vendor Print</span>
		</div>
		<div class="application-location">
		</div>
	</div>
	
	<table class="form-table">
		<colgroup>
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="20%" />
			<col width="13%" />
			<col width="*" />
		</colgroup>
		
		<tr height="25">
			<th style="text-align: left;">검토부서</th>
			<td>
				<%= InputText.get("EPART_DEPT_NAME", prePayment.get("EPART_DEPT_NAME"), 48, 60, "desc=검토부서, readOnly") %>
			</TD>				
			<th style="text-align: left;">검토자</th>
						<TD>
			<INPUT type='hidden' name="VP_CHK_EMPNO" value="<%=prePayment.get("VP_CHK_EMPNO")%>">
			<%= InputText.get("VP_CHK_EMPNM", prePayment.get("VP_CHK_EMPNM"), 21, 60, "desc=검토자, readOnly") %>
			<IMG id=btnevalemp src="/img/buyer/button/bt_search_right.gif" alt="검토자" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:SearchUser('<%=prePayment.get("VP_CHK_EMPNM")%>','<%=prePayment.get("VP_CHK_EMPNO")%>','N');">
			</TD>
			<th style="text-align: left;">검토일자</th>
			<td>
				<%= InputText.get("VP_END_DY", Formatter2.formatDate(prePayment.get("VP_END_DY"), "-"), 40, 30, "class=input_blank, readOnly=white, string, left, perSize, tabIndex=-1", "string") %>
				<A href="JavaScript:calendar('VP_END_DY');"><IMG src="/img/supplier/template/bt_calender.gif" alt="달력" border="0" align="absmiddle"></A>
			</TD>			
		</tr>
		<tr height="25">
			<th style="text-align: left;">검토항목</th>
			<td colspan="3">
				<%= InputText.get("VP_DESC", prePayment.get("VP_DESC"), 98, 1000, "string, left, perSize", "string") %>
			</TD>
			<th style="text-align: left;">상태</th>
			<td><%= prePayment.get("VP_STATUS_NM") %></TD>
		</tr>
		<tr height="25" id="return_reson_area">
			<th style="text-align: left;">반려사유</th>
			<td colspan="5"><%= prePayment.get("VP_RTN_REASON") %></TD>
		</tr>
		<tr height="25"> 
			<th>의견</th>
			<td colspan="5">
				<textarea name="opinion" id="opinion" style="width:98%; height:70px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget"><%=prePayment.get("VP_OPINION") %></textarea>
			</td>					
  		</tr>
	</table>
	
	
	
</form>