<%@ 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 = "";
	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("PUR1100T", payVo.get("payreq_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="700" border="0" cellspacing="0" cellpadding="0">
	<tbody>
    <TR>
        <TD align="center">
            <TABLE width="700" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
	          <COLGROUP>
	            <COL width="18%">
	            <COL width="31%">
	            <COL width="18%">
	            <COL width="31%">
	          </COLGROUP>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>계약번호</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("ord_doc_no") %>
	          		<IMG src="<%=link %>/img/supplier/button/bt_attach_file.gif" id="dashBoard" alt="대시보드" align="top" onClick="openDash('<%=payVo.get("PUR_CONT_ID")%>')" class="button">
	          		</td>
	          		<td class="list_title4" nowrap>작성일자</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("req_date") %></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title3" nowrap>작성자</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("REQ_CHARGE_NAME") %></td>
	          		<td class="list_title4" nowrap>협조부서</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("SUB_DEPT_NM") %></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>현장코드</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("DEPT_CD") %>&nbsp;</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("CURRENCY_GB")%></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title3" nowrap>현장명</td>
	          		<td class="list_data" nowrap align="left" colspan="3"><input type="text" class="input" id="DEPT_NAME" style="width:95%;"  value='<%=payVo.get("DEPT_NAME") %>'></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title3" nowrap>계약명</td>
	          		<td class="list_data" nowrap align="left" colspan="3"><input type="text" class="input" id="CST_DOC_NAME" style="width:95%;"  value='<%= StringUtils.cvtHTML3(payVo.get("CST_DOC_NAME"))%>'></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title5" nowrap>계약업체명</td>
	          		<td class="list_data" nowrap align="left"><input type="text" class="input" id="CORP_KOR" style="width:95%;"  value='<%=payVo.get("CORP_KOR") %>'></td>
	          		<td class="list_title4" nowrap>대표이사</td>
	          		<td class="list_data" nowrap align="left">&nbsp;<%=payVo.get("BOSS_NAME") %></td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title5" nowrap>총계약금액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("ORD_AMT") %> &nbsp;</td>
	          		<td class="list_title4" nowrap>선급금액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("PREPAY_AMT") %> &nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>지급구분</td>
	          		<td class="list_data" nowrap align="center">
	          		
	          		
	          		<input type="checkbox" name="prepay" <%=prepay_chk %>>선급금
	          		
	          		
	          		<%
	          		if(payVo.get("DEPOSIT_CD").equals("2")){
	          			
   	          		%>
   	          		<input type="checkbox" name="mid" <%=mid_chk %>>중도금(<%=payVo.getInt("DEPOSIT_SEQ") %>차)
   	          		<%
   	          		
	          		}else{
	          		%>
	          		<input type="checkbox" name="mid" <%=mid_chk %>>중도금
	          		<%	
	          		}
	          		%>
	          		
	          		<%
	          		if(payVo.get("DEPOSIT_CD").equals("3")){
	          			
	          		%>
	          		<input type="checkbox" name="rmdr" <%=rmdr_chk %>>잔금(<%=payVo.getInt("DEPOSIT_SEQ") %>차<%=success_text %>)
	          		
	          		<%
	          		
	          		}else{
	          			
	          		%>
	          		<input type="checkbox" name="rmdr" <%=rmdr_chk %>>잔금<%=success_text %>
	          		<%
	          		}
	          		%>
	          		
	          		</td>
	          		<td class="list_title6" nowrap>기선급공제액</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>금회선급공제액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CUR_BEF_PREPAY_SUPPLYAMT") %> &nbsp;</td>
	          		<td class="list_title4" nowrap>선급잔액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("REMAINDER_PREPAY_AMT") %> &nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>기지불액</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("PAYED_AMT") %> &nbsp;<%-- (<%=payVo.get("PAYED_PERCENT") %>%)&nbsp; --%></td>
	          		<td class="list_title4" nowrap>전기성고</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("BEF_ACMP_AMT") %> &nbsp;(<%=payVo.get("BEF_ACMP_PERCENT")%>%)&nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title5" nowrap>금회청구액</td>
	          		<%-- <td class="list_data" nowrap align="right"><%=payVo.get("CUR_REQ_AMT") %> &nbsp;(<%=payVo.get("CUR_REQ_PERCENT") %>%)&nbsp;</td> --%>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CUR_REQ_AMT") %> &nbsp;</td>
	          		<td class="list_title5" nowrap>금회기성고</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CUR_ACMP_AMT") %> &nbsp;(<%=payVo.get("CUR_ACMP_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("CUR_PAYED_AMT") %> &nbsp;(<%=payVo.get("CUR_PAYED_PERCENT") %>%)&nbsp;</td> --%>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CUR_PAYED_AMT") %> &nbsp;</td>
	          		<td class="list_title" nowrap align="center">금회포함기성고</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("CUR_BEF_ACMP_AMT") %> &nbsp;(<%=payVo.get("CUR_BEF_ACMP_PERCENT") %>%)&nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title_2" nowrap align="center">잔&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;액</td>
	          		<%-- <td class="list_data" nowrap align="right"><%=payVo.get("REMAINDER_AMT") %> &nbsp;(<%=payVo.get("REMAINDER_ACMP_PERCENT") %>%)&nbsp;</td> --%>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("REMAINDER_AMT") %> &nbsp;</td>
	          		<td class="list_title4" nowrap>미기성고</td>
	          		<td class="list_data" nowrap align="right"><%=payVo.get("REMAINDER_ACMP_AMT") %> &nbsp;(<%=payVo.get("REMAINDER_ACMP_PERCENT") %>%)&nbsp;</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title6" nowrap align="Center" >외국환거래<BR>신고대상</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("PUR_CONT_ID")%>', '<%=payVo.get("PAYREQ_ID") %>', '<%=payVo.get("CORP_ID") %>');" class="button">
	                    <%} %>
	          		</td>
	          	</tr>
	          	<tr height="23" align="center">
	          		<td class="list_title4" nowrap>지급사유</td>
	          		<td class="list_data" nowrap align="left" colspan="3"><input type="text" class="input" id="DEPOSIT_RESN" style="width:95%;"  value='<%=payVo.get("DEPOSIT_RESN") %>'></td>
	          	</tr>
	          	<tr height="112" align="center">
	          		<td class="list_title4" nowrap>특기사항</td>
	          		<td class="list_data" nowrap align="left" valign="middle" colspan="3">
	          			<%=payVo.get("RE_MARKS").replaceAll("\n", "<br//>")%>
	          		</td>
	          	</tr>
	          	<tr align="center">
	          		<td class="list_title4" nowrap>첨부서류</td>
	          		<td class="list_data" nowrap align="left" valign="top" colspan="3">&nbsp;
	          		<table>
	          			<TR>
					<%
						if(purchaseFileRow.size() > 0){
							int i_mod = 0;
							for(int i = 0; purchaseFileRow.size() > i; i++){
								i_mod = i%3;
								if(i_mod == 0){ %>
						<TR>
					<%			} %>
							<td class="list_data" width="2%">
								<input type="checkbox" name="doc_cd" value="<%=purchaseFileRow.getRow(i).get("DETAILCD") %>" style="cursor:pointer;" <%if(!purchaseFileRow.getRow(i).get("DOC_CD").equals("")){out.print("checked");} %>>
							</td>
							<td class="list_data" width="20%">
								<%-- <%=acmpFileRow.getRow(i).get("DETAILNM").replace(" ", "<BR>") %> --%>
								<%=purchaseFileRow.getRow(i).get("DETAILNM") %>
							</td>
							<td class="list_data" width="7%" height="24">
								<IMG src="<%=link %>/img/supplier/button/bt_attach_file.gif" id="<%=purchaseFileRow.getRow(i).get("DETAILCD") %>" alt="첨부파일 관리" align="top" style="display:<%if(!purchaseFileRow.getRow(i).get("DOC_CD").equals("")){out.print("inline");}else{out.print("none");} %>" onClick="open_apppend_file('<%=payVo.get("payreq_id") %>', '<%=purchaseFileRow.getRow(i).get("DETAILCD") %>');" class="button">
							</td>
					<%	if(i_mod == 2) { %>		
						</TR>
					<%	} %>		
				<%
					}
					for(int i=i_mod+1; i<3; i++){ %>
						<td></td>
				<%	}
					if(i_mod == 0 || i_mod == 1){ %>
						</TR>	
				<%	}
				}
				%>
					</table>
	          		</td>
	          	</tr>
            </TABLE>
        </TD>
    </TR>
<%--     <TR>
    	<TD>
    		<TABLE width="700" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#AEAFAF" border="1">
    		 <COLGROUP>
	            <COL width="100px">
	            <COL width="100px">
	            <COL width="100px">
	            <COL width="109px">
	            <COL width="50px">
	            <COL width="50px">
	            <COL width="50px">
	            <COL width="100px">
	            <COL width="100px">
	          </COLGROUP>
	          <tr height="23" align="center">
	          	<td class="list_title" nowrap align="center">입고번호</td>
	          	<td class="list_title" nowrap align="center">자재코드</td>
	          	<td class="list_title" nowrap align="center">자재명</td>
	          	<td class="list_title" nowrap align="center">규격</td>
	          	<td class="list_title" nowrap align="center">단위</td>
	          	<td class="list_title" nowrap align="center">입고수량</td>
	          	<td class="list_title" nowrap align="center">입고단가</td>
	          	<td class="list_title" nowrap align="center">입고금액</td>
	          </tr>
	          <%if (listRowSet.size() > 0){
	          		for(int i = 0; i < listRowSet.size(); i++){
				%>	          	
	          		<tr height="23" align="center">
	          			<td class="list_data" nowrap align="center">&nbsp;<%=listRowSet.getRow(i).get("STOCK_NO") %></td>
	          			<td class="list_data" nowrap align="center">&nbsp;<%=listRowSet.getRow(i).get("MATERIAL_CD") %></td>
	          			<td class="list_data" nowrap align="left">&nbsp;<%=listRowSet.getRow(i).get("MATERIAL_NAME") %></td>
	          			<td class="list_data" nowrap align="center">&nbsp;<%=listRowSet.getRow(i).get("MATERIAL_SPEC") %></td>
	          			<td class="list_data" nowrap align="center">&nbsp;<%=listRowSet.getRow(i).get("UNIT_KIND") %></td>
	          			<td class="list_data" nowrap align="right">&nbsp;<%=PCMSUtil.strPoint(Formatter.formatCurrency(listRowSet.getRow(i).get("ITEM_QTY")),0) %></td>
	          			<td class="list_data" nowrap align="right">&nbsp;<%=PCMSUtil.strPoint(Formatter.formatCurrency(listRowSet.getRow(i).get("ITEM_PRI")),0) %></td>
	          			<td class="list_data" nowrap align="right">&nbsp;<%=PCMSUtil.strPoint(Formatter.formatCurrency(listRowSet.getRow(i).get("ITEM_AMT")),0) %></td>
	          		</tr>
	          	<%	
	          		}
	          	}else{
	          		
	          	}
	          	%>
    		</table>
    	</TD>
    </TR> --%>
  </tbody>
</TABLE>
<table><tr><td style="display:none;" id=doctitle_1 class=FIELD><%=params.get("docTitle") %></td></tr></table>
<br>
