<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.*"%>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.web.*" %>
<%@ page import="kr.co.hsnc.common.sql.*"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.util.*"%>
<%@ page import="com.udapsoft.waf.system.HandlerStorage"%>
<%@ page import="kr.co.hsnc.common.util.ValueObject"%>
<%@ page import="kr.co.hsnc.common.message.WAFMessage"%>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<%@ page import="com.udapsoft.waf.common.util.StringUtils" %>
<%@ page import="kr.co.udapsoft.common.util.PCMSUtil" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@ page import="com.udapsoft.waf.common.util.Formatter2"%>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />

<%
	ctx.init(request, response);
	String link = ctx.getServerDomain();

    HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject params = storage.getParams();

	WAFMessage wafMessage = WAFMessage.getInstance();
	
	ValueObject payVo  = storage.getValueObject("payList");
	
	RowSet listRowSet =  null;
	listRowSet 	   = storage.getRowSet("listRowSet");
	RowSet purchaseFileRow =  null;
	purchaseFileRow 	   = storage.getRowSet("purchaseFileRow");
	
	//지급구분
	String prepay_chk = "checked";
	String mid_chk = "";
	String rmdr_chk = "";
	
/* 	if(payVo.get("deposit_cd").equals("1")){
		prepay_chk = "checked";
	}else if(payVo.get("deposit_cd").equals("2")){
		mid_chk = "checked";
	}else if(payVo.get("deposit_cd").equals("3")){
		rmdr_chk = "checked";
	} */
	
	RowSet rowSet = FileManager.getFileList("PREPAYMENTS_GIVEUP", payVo.get("PREPAY_ID"));

	RowSet rowSet2 = FileManager.getFileList("TAX_BILL", payVo.get("PREPAY_ID"));	//세금계산서

	RowSet rowSet3 = FileManager.getFileList("PREPAYMENTS_INVOICE", payVo.get("PREPAY_ID"));	//invoice

	RowSet rowSet1 = FileManager.getFileList("PREPAYMENTS_BILLING", payVo.get("PREPAY_ID"));
	
	String success_text = "";
	
//	if(payVo.get("CUR_PAYED_AMT").replaceAll(",", "").equals(payVo.get("ORD_AMT").replaceAll(",", ""))){
// 		success_text = "-<font color='red'>완료</font>";
		//success_text = "-<font color='red'>최종</font>";
//	}
	
	//if(payVo.get("REMAINDER_AMT").replaceAll(",", "").equals("0")){
// 		success_text = "-<font color='red'>완료</font>";
		//success_text = "-<font color='red'>최종</font>";
	//}
	
	//int intDigit = 0;
%>


<br>

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
	<tbody>
    <TR>
        <TD align="center">
            <TABLE width="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          <COLGROUP>
	            <COL width="20%">
	            <COL width="20%">
	            <COL width="20%">
	            <COL width="40%">
	          </COLGROUP>
	          	<tr height="23">
	          		<td class="list_title3" nowrap>현장명</td>
	          		<td class="list_data" nowrap align="left"><input type="text" class="input" id="DEPT_NAME" style="width:95%;"  value='<%=payVo.get("DEPT_NAME") %>(<%=payVo.get("DEPT_CD") %>)'></td>
	          		<td class="list_title4" nowrap>작성일자</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("TAX_DY") %></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>계약번호</td>
	          		<td class="list_data" nowrap align="left" colspan="1">&nbsp;<%=payVo.get("CON_DOC_NO") %></td>
	          		<td class="list_title3" nowrap>작성자</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("USER_NAME") %></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title3" nowrap>계약명</td>
	          		<td class="list_data" nowrap align="left"><input type="text" class="input" id="BUILD_NAME" style="width:95%;"  value="<%=payVo.get("BUILD_NAME") %>"></td>
	          		<td class="list_title_2" nowrap>통&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;화</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%= payVo.get("CON_CUR_CD")%></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title5" nowrap>계약업체명</td>
	          		<td class="list_data" nowrap align="left" colspan="1">&nbsp;<%=payVo.get("CORP_KOR") %>&nbsp;</td>
	          		<td class="list_title4" nowrap>대표이사</td>
	          		<td class="list_data" nowrap align="left" colspan="1">&nbsp;<%= StringUtils.cvtHTML3(payVo.get("BOSS_NAME"))%></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>지급구분</td>
	          		<td class="list_data" nowrap align="left"><input type="checkbox" name="prepay" checked>선급금
	          													<input type="checkbox" name="mid">중도금(&nbsp;차)
	          													<input type="checkbox" name="mid1">잔금(&nbsp;차)
	          		</td>
	          		<td class="list_title4" nowrap>신청구분</td>
	          		<td class="list_data" nowrap align="left" colspan="1">&nbsp;<%=payVo.get("REQ_DIV_CD") %>&nbsp;</td>	          		
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title5" nowrap>총계약금액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CON_AMT") %> &nbsp;(100.0)&nbsp;</td>
	          		<td class="list_title5" nowrap>계약선급금</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("PREPAY_AMT") %> &nbsp;(<%=payVo.get("PREPAY_AMT_PERCENT") %>%)&nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">계약 공급가 과세</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CON_SUPPLY_AMT") %> &nbsp;</td>
					<td class="list_title" nowrap align="center">계약 선급금 과세</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("PREPAY_SUPPLY_AMT") %> &nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">계약 부가세 </td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CON_SURTAX_AMT") %> &nbsp;</td>
	          		<td class="list_title" nowrap align="center">선급 부가세</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("PREPAY_SURTAX_AMT") %> &nbsp;</td>
	          	</tr>	          	
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">신청 선급금 합계</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("REQ_PREPAY_AMT") %> &nbsp;(<%=payVo.get("REQ_PREPAY_PERCENT") %>%)&nbsp;</td>
	          		<td class="list_title" nowrap align="center">포기 선급금 합계</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("GIVE_AMT") %> &nbsp;(<%=payVo.get("GIVE_PERCENT") %>%)&nbsp;</td>	          		
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">신청 선급금 공급가</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("REQ_PREPAY_SUPPLY_AMT") %> &nbsp;</td>
	          		<td class="list_title" nowrap align="center">포기 선급금 공급가</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("GIVE_SUPPLY_AMT") %> &nbsp;</td>	          	
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">신청 선급금 부가세</td>
	          		<td class="list_data" nowrap align="right" colspan="1"><%=payVo.get("REQ_PREPAY_SURTAX_AMT") %> &nbsp;</td>
	          		<td class="list_title" nowrap align="center">포기 선급금 부가세</td>
	          		<td class="list_data" nowrap align="right" colspan="1"><%=payVo.get("GIVE_SURTAX_AMT") %> &nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title" nowrap align="center">외국환거래 신고대상</td>
	          		<td class="list_data" nowrap align="left" colspan="3">&nbsp;<%=payVo.get("FOREIGN_NM")%> 
	          		    <%if(!payVo.get("FOREIGN_CHK").equals("A")){%>
	                         &nbsp;<IMG src="<%=link %>/img/buyer/button/bt_attach_file.gif" id="bt_foreign" alt="외국환거래" align="top" valign="top" onClick="open_foreign('<%=payVo.get("SUB_CONT_ID")%>', '<%=payVo.get("PREPAY_ID") %>', '<%=payVo.get("CON_CORP_ID") %>');" class="button">
	                    <%} %></td>
	          	</tr>
			</TABLE>
			<BR/>
	        <TABLE width="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          	<COLGROUP>
	            	<COL width="20%">
	            	<COL width="20%">
	            	<COL width="20%">
	            	<COL width="40%">
	          		</COLGROUP>  	
				<tr height="23" align="center">
					<td class="list_title" nowrap align="center" colspan="4">첨부파일</td>
				</tr>
 	          	<tr height="30" align="left">
 	          	<%
		          		if(rowSet.size() > 0){
				%>
	          			<td class="list_title1" nowrap align="left">&nbsp;선급금포기각서</td>
				<%		          			
		          		}else{
   				%>
   						<td class="list_title1" nowrap align="left">&nbsp;선급금포기각서(해당없음)</td>
   				<%		          			
		          		}
 	            %>
	          		<td class="list_data" nowrap align="left" colspan="3">
	          		<table width="100%" height="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          		<tr>
	          			<td class="list_data" width="470px" align="top" valign="top"  nowrap>
		          		<%
		          		if(rowSet.size() > 0){
		          			for(int i = 0; rowSet.size() > i; i++){
		          				if(rowSet.getRow(i).get("FILE_NAME").length() > 35){
		          		%>
		          				<%= rowSet.getRow(i).get("FILE_NAME").substring(0, 35)+"..."%>
		          				<%= rowSet.getRow(i).get("FILE_EXT")%>
		          		<%
		          					
		          				}else{
		          		%>
		          				<%= rowSet.getRow(i).get("FILE_NAME")%>
		          		<%
		          				}
		          		%>
		          		( <%=rowSet.getRow(i).get("FILE_SIZE") %> )
		          		<br>
		          		<%
		          			}
		          		}
		          		%>&nbsp;
						</td>
						<td class="list_data" nowrap>
							<IMG src="<%=link %>/img/buyer/button/bt_change.gif" id="bt_attach_file" alt="첨부파일 관리" align="top" valign="top" onClick="open_apppend_file('PREPAYMENTS_GIVEUP', '<%=payVo.get("PREPAY_ID") %>');" class="button">
						</td>
					</tr>
	          		</table>
					</td>
	          	</tr>
<%
	if(rowSet2.size() > 0){
%>
 	          	<tr height="30" align="center">
	       			<td class="list_title1" nowrap align="left">&nbsp;세금계산서</td>
	          		<td class="list_data" nowrap align="left" colspan="3">
	          		<table width="100%" height="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          		<tr>
	          			<td class="list_data" width="470px" align="top" valign="top"  nowrap>
		          		<%
		          		if(rowSet2.size() > 0){
		          			for(int i = 0; rowSet2.size() > i; i++){
		          				if(rowSet2.getRow(i).get("FILE_NAME").length() > 35){
		          		%>
		          				<%= rowSet2.getRow(i).get("FILE_NAME").substring(0, 35)+"..."%>
		          				<%= rowSet2.getRow(i).get("FILE_EXT")%>
		          		<%
		          					
		          				}else{
		          		%>
		          				<%= rowSet2.getRow(i).get("FILE_NAME")%>
		          		<%
		          				}
		          		%>
		          		( <%=rowSet2.getRow(i).get("FILE_SIZE") %> )
		          		<br>
		          		<%
		          			}
		          		}
		          		%>&nbsp;
						</td>
						<td class="list_data" nowrap>
							<IMG src="<%=link %>/img/buyer/button/bt_change.gif" id="bt_attach_file" alt="첨부파일 관리" align="top" valign="top" onClick="open_apppend_file('TAX_BILL', '<%=payVo.get("PREPAY_ID") %>');" class="button">
						</td>
					</tr>
	          		</table>
					</td>
	          	</tr>
<%
	}
%>
<%
	if(rowSet3.size() > 0){
%>
 	          	<tr height="30" align="center">
	       			<td class="list_title1" nowrap align="left">&nbsp;Invoice</td>
	          		<td class="list_data" nowrap align="left" colspan="3">
	          		<table width="100%" height="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          		<tr>
	          			<td class="list_data" width="470px" align="top" valign="top"  nowrap>
		          		<%
		          		if(rowSet3.size() > 0){
		          			for(int i = 0; rowSet3.size() > i; i++){
		          				if(rowSet3.getRow(i).get("FILE_NAME").length() > 35){
		          		%>
		          				<%= rowSet3.getRow(i).get("FILE_NAME").substring(0, 35)+"..."%>
		          				<%= rowSet3.getRow(i).get("FILE_EXT")%>
		          		<%
		          					
		          				}else{
		          		%>
		          				<%= rowSet3.getRow(i).get("FILE_NAME")%>
		          		<%
		          				}
		          		%>
		          		( <%=rowSet3.getRow(i).get("FILE_SIZE") %> )
		          		<br>
		          		<%
		          			}
		          		}
		          		%>&nbsp;
						</td>
						<td class="list_data" nowrap>
							<IMG src="<%=link %>/img/buyer/button/bt_change.gif" id="bt_attach_file" alt="첨부파일 관리" align="top" valign="top" onClick="open_apppend_file('PREPAYMENTS_INVOICE', '<%=payVo.get("PREPAY_ID") %>');" class="button">
						</td>
					</tr>
	          		</table>
					</td>
	          	</tr>
<%
	}
%>	          	
 	          	<tr height="30" align="center">
	       			<td class="list_title1" nowrap align="left">&nbsp;대금청구</td>
	          		<td class="list_data" nowrap align="left" colspan="3">
	          		<table width="100%" height="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          		<tr>
	          			<td class="list_data" width="470px" align="top" valign="top"  nowrap>
		          		<%
		          		if(rowSet1.size() > 0){
		          			for(int i = 0; rowSet1.size() > i; i++){
		          				if(rowSet1.getRow(i).get("FILE_NAME").length() > 35){
		          		%>
		          				<%= rowSet1.getRow(i).get("FILE_NAME").substring(0, 35)+"..."%>
		          				<%= rowSet1.getRow(i).get("FILE_EXT")%>
		          		<%
		          					
		          				}else{
		          		%>
		          				<%= rowSet1.getRow(i).get("FILE_NAME")%>
		          		<%
		          				}
		          		%>
		          		( <%=rowSet1.getRow(i).get("FILE_SIZE") %> )
		          		<br>
		          		<%
		          			}
		          		}
		          		%>&nbsp;
						</td>
						<td class="list_data" nowrap>
							<IMG src="<%=link %>/img/buyer/button/bt_change.gif" id="bt_attach_file" alt="첨부파일 관리" align="top" valign="top" onClick="open_apppend_file('PREPAYMENTS_BILLING', '<%=payVo.get("PREPAY_ID") %>');" class="button">
						</td>
					</tr>
	          		</table>
					</td>
	          	</tr>
            </TABLE>
            <br/>
	    <TABLE width="100%" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
		          <COLGROUP>
		            <COL width="20%">
		            <COL width="80%">
		          </COLGROUP>
		    <td class="list_title1" nowrap align="left" >&nbsp;대시보드</td>
		    <td class="list_data" nowrap align="left">
		    	&nbsp;<IMG src="<%=link %>/img/buyer/button/bt_change.gif" id="dashBoard" alt="대시보드" align="top" valign="top" onClick="openDash('<%=payVo.get("SUB_CONT_ID")%>')" class="button">
		    </td>
	    </TABLE>
        </TD>
    </TR>
  </tbody>
</TABLE>
<table><tr><td style="display:none;" id=doctitle_1 class=FIELD><%=params.get("docTitle") %></td></tr></table>
<br>
