<%--
  - FileName   : applicationRequestList.jsp
  - Author(s)  : ok
  - Date       : 2014.07.04
  - Copyright  : Copyright (c) 2013 www.udapsoft.co.kr, 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"%>


<%@ 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();
  	
%>
<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("#btnCreate").click(function() {
			
			if(sheet1.RowCount("U") == 0){
				alert("신규생성할 기성대상건을 선택하세요.");
				return;
			}
			
 			if (confirm("기성 정보를 생성 하시겠습니까?")) {
				jQuery("#fevent").val("SAVE_DATA");
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/payment/ApplicationRequestList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
			}
		}); 
		
		jQuery("#btnClose").click(function() {
			//setTimeout(function(){parent.searchAccDeptClose(null);},100);
			parent.callback_getData();
		}); 
		
		pageinit();
		
	}
	
	function pageinit(){
		
		searchData();
		
	}
	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30, MergeSheet:msHeaderOnly};
		init_sheet.Cols = [
		    			{Header:'상태',				Type:"Status", 			SaveName:"STATUS", 				Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'선택',				Type:"CheckBox",		SaveName:"CHECKBOX", 			Width:30, 	Align:"Center"},
		    			{Header:'현장명',			Type:"Text", 			SaveName:"DEPT_NAME",			Width:120, 	Align:"Left"},
		    			{Header:'계약명',			Type:"Text", 			SaveName:"BUILD_NAME",			Width:120, 	Align:"Left"},
		    			{Header:'공사기간',			Type:"Text", 			SaveName:"START_END_WORK_DATE", Width:90, 	Align:"Center"},
		    			{Header:'공급가',			Type:"Int", 			SaveName:"CON_SUPPLY_AMT", 		Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'부가세',			Type:"Int", 			SaveName:"CON_SURTAX_AMT", 		Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'합계',				Type:"Int", 			SaveName:"CON_AMT", 			Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'지급차수',			Type:"Text", 			SaveName:"ACMP_NO", 			Width:30, 	Align:"Center"},
		    			{Header:'금회기성',			Type:"Int", 			SaveName:"FUND_AMT", 			Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'누계기성',			Type:"Int", 			SaveName:"TOT_FUND_AMT", 		Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'잔여기성',			Type:"Int", 			SaveName:"MOD_FUND_AMT", 		Width:50, 	Align:"Right", Format:"#,##0"},
		    			{Header:'선금처리',			Type:"Text", 			SaveName:"P_STATUS_CD", 		Width:50, 	Align:"Right", Hidden:"True"},
		    			{Header:'선금처리',			Type:"Text", 			SaveName:"STATUS_NM", 		Width:50, 	Align:"Center" },
		    			
		    			{Header:'SUB_CONT_ID',				Type:"Text", 			SaveName:"SUB_CONT_ID", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_CORP_ID',				Type:"Text", 			SaveName:"CON_CORP_ID", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'MOD_NO',					Type:"Text", 			SaveName:"MOD_NO", 				Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'ACMP_YYYYMM',				Type:"Text", 			SaveName:"ACMP_YYYYMM", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'ACMP_DATE',				Type:"Text", 			SaveName:"ACMP_DATE", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_START_DATE',			Type:"Text", 			SaveName:"CON_START_DATE", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_END_DATE',				Type:"Text", 			SaveName:"CON_END_DATE", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'START_WORK_DATE',			Type:"Text", 			SaveName:"START_WORK_DATE", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'END_WORK_DATE',			Type:"Text", 			SaveName:"END_WORK_DATE", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_CUR_CD',				Type:"Text", 			SaveName:"CON_CUR_CD", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_SUPPLY_TAMT',			Type:"Text", 			SaveName:"CON_SUPPLY_TAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_SUPPLY_NAMT',			Type:"Text", 			SaveName:"CON_SUPPLY_NAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'FUND_TAMT',				Type:"Text", 			SaveName:"FUND_TAMT", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'FUND_NAMT',				Type:"Text", 			SaveName:"FUND_NAMT", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PAY_DEDUCT_AMT',			Type:"Text", 			SaveName:"PAY_DEDUCT_AMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PAY_DEDUCT_TAMT',			Type:"Text", 			SaveName:"PAY_DEDUCT_TAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PAY_DEDUCT_NAMT',			Type:"Text", 			SaveName:"PAY_DEDUCT_NAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PAY_DEDUCT_RATE',			Type:"Text", 			SaveName:"PAY_DEDUCT_RATE", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'REQU_AMT',					Type:"Text", 			SaveName:"REQU_AMT", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'REQU_SUPPLY_AMT',			Type:"Text", 			SaveName:"REQU_SUPPLY_AMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'REQU_SUPPLY_TAMT',			Type:"Text", 			SaveName:"REQU_SUPPLY_TAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'REQU_SUPPLY_NAMT',			Type:"Text", 			SaveName:"REQU_SUPPLY_NAMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'REQU_SURTAX_AMT',			Type:"Text", 			SaveName:"REQU_SURTAX_AMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_FUND_AMT',				Type:"Text", 			SaveName:"PRE_FUND_AMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_FUND_TAMT',			Type:"Text", 			SaveName:"PRE_FUND_TAMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_FUND_NAMT',			Type:"Text", 			SaveName:"PRE_FUND_NAMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_PAY_DEDUCT_AMT',		Type:"Text", 			SaveName:"PRE_PAY_DEDUCT_AMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_PAY_DEDUCT_TAMT',		Type:"Text", 			SaveName:"PRE_PAY_DEDUCT_TAMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_PAY_DEDUCT_NAMT',		Type:"Text", 			SaveName:"PRE_PAY_DEDUCT_NAMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_PAY_DEDUCT_RATE',		Type:"Text", 			SaveName:"PRE_PAY_DEDUCT_RATE", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_REQU_AMT',				Type:"Text", 			SaveName:"PRE_REQU_AMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_REQU_SUPPLY_AMT',		Type:"Text", 			SaveName:"PRE_REQU_SUPPLY_AMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_REQU_SUPPLY_TAMT',		Type:"Text", 			SaveName:"PRE_REQU_SUPPLY_TAMT",Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_REQU_SUPPLY_NAMT',		Type:"Text", 			SaveName:"PRE_REQU_SUPPLY_NAMT",Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PRE_REQU_SURTAX_AMT',		Type:"Text", 			SaveName:"PRE_REQU_SURTAX_AMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'PROOF_CD',					Type:"Text", 			SaveName:"PROOF_CD", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'STATUS_CD',				Type:"Text", 			SaveName:"STATUS_CD", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'DEPT_CD',					Type:"Text", 			SaveName:"DEPT_CD", 			Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_FUND_TAMT',			Type:"Text", 			SaveName:"TOT_FUND_TAMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_FUND_NAMT',			Type:"Text", 			SaveName:"TOT_FUND_NAMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_PAY_DEDUCT_AMT',		Type:"Text", 			SaveName:"TOT_PAY_DEDUCT_AMT", 	Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_PAY_DEDUCT_TAMT',		Type:"Text", 			SaveName:"TOT_PAY_DEDUCT_TAMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_PAY_DEDUCT_NAMT',		Type:"Text", 			SaveName:"TOT_PAY_DEDUCT_NAMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_PAY_DEDUCT_RATE',		Type:"Text", 			SaveName:"TOT_PAY_DEDUCT_RATE", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_REQU_AMT',				Type:"Text", 			SaveName:"TOT_REQU_AMT", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_REQU_SUPPLY_AMT',		Type:"Text", 			SaveName:"TOT_REQU_SUPPLY_AMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_REQU_SUPPLY_TAMT',		Type:"Text", 			SaveName:"TOT_REQU_SUPPLY_TAMT",Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_REQU_SUPPLY_NAMT',		Type:"Text", 			SaveName:"TOT_REQU_SUPPLY_NAMT",Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TOT_REQU_SURTAX_AMT',		Type:"Text", 			SaveName:"TOT_REQU_SURTAX_AMT", Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'SUPP_DIRECT_YN',			Type:"Text", 			SaveName:"SUPP_DIRECT_YN", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'LABOR_USE_YN',				Type:"Text", 			SaveName:"LABOR_USE_YN", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			
		    			{Header:'TAX_CHARG_NM',				Type:"Text", 			SaveName:"TAX_CHARG_NM", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TAX_CHARG_HP',				Type:"Text", 			SaveName:"TAX_CHARG_HP", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'TAX_CHARG_EMAIL',			Type:"Text", 			SaveName:"TAX_CHARG_EMAIL", 	Width:0, 	Align:"Center", Hidden:"True"}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(true);
		
		setGridSize();
	}

	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	    
	    //2015.11.17
	    var frmObj = document.getElementsByName('form1')[0];
	    for(i=1; i<=sheet1.RowCount(); i++){
	 		if(sheet1.GetCellValue(i, 'P_STATUS_CD') !=  '10' && sheet1.GetCellValue(i, 'P_STATUS_CD') !=  '11'  && sheet1.GetCellValue(i, 'P_STATUS_CD') !=  ''){
	 			sheet1.SetRowEditable(i, false);
			}
			if(sheet1.GetCellValue(i, 'END_WORK_DATE') < frmObj.searchDate.value + '-00' ){
				sheet1.SetRowEditable(i, false);
			}
		}	 
	    
	}
	
	/**
	 *	IBSheet Event: Save End(IBSheet 데이터 저장 CallBack)
	 */
	function sheet1_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	alert("신규로 기성건이 생성되었습니다. \n\n 외주_기성현황에서 확인 하실수 있습니다.");
	    } else {
	    	alert(msg);
	    	
        }
	    searchData();
	}
	
	/**
	 *	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) {

/* 		if (sheet1.ColSaveName(Col) == "BUILD_NAME1") {	//계약명

 			jQuery("#selectSubContId").val(sheet1.GetCellValue(Row, "SUB_CONT_ID"));	//외주계약서ID
 			jQuery("#acmpId").val(sheet1.GetCellValue(Row, "ACMP_ID"));					//기성ID
 			jQuery("#acmpYyyymm").val(sheet1.GetCellValue(Row, "ACMP_YYYYMM"));			//기성년월
 			jQuery("#conCorpId").val(sheet1.GetCellValue(Row, "CON_CORP_ID"));			//계약업체ID
 			jQuery("#acmpNo").val(sheet1.GetCellValue(Row, "ACMP_NO"));					//기성차수
 			
			jQuery("#fevent").val("");
			jQuery("#form1").attr("action", "/portal/payment/ResolutionRequest.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();
			
		} */
		
	}
	
	function doKeyPress() {
	    if( event.keyCode == 13 ) {
	    	jQuery("#btnSearch").click();
	    }
	}	
	
	function calendar(thisDayObj){
		dlgMCalendar(thisDayObj);
		
	}		
	
	function searchData(){

		jQuery("#fevent").val("GET_DATA");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/payment/ApplicationRequestList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10000, ""); 

	}

	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
	}
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<BODY>
<form id="form1" name="form1" method="post" modular:type="search">
	<INPUT type="hidden" name="fevent" id="fevent" value="">
	<INPUT type="hidden" name="userCorpId" id="userCorpId" value="<%=params.get("userCorpId")%>">

	<!-- 프로그램 제목 -->
	<div align="left" id="title">
		<ul>
			<li>신규기성 신청대상</li>
		</ul>
	</div> 
	
	<!-- 검색조건 영역 : 시작 -->
	<table class="search-form-table" style="width: 970px">
		<colgroup>
			<col width="10%" />
			<col width="*" />
			<col width="25%" />
		</colgroup>
		<TR height="25"> 
		<!-- 검색조건 타이틀 1 -->
			<Th>기성년월</Th>
			<TD>
				<%= InputText.get("searchDate", Formatter.formatDate(params.get("searchDate"), "-"), 30, 30, "class=input_blank, readOnly=white, string, left, readOnly, tabIndex=-1", "String") %>
			</TD>
			<TD class="button">      
				<!-- 검색버튼 영역 : 시작 -->
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnCreate">신규기성생성</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnClose">닫기</a></span>
 				<!-- 검색버튼 영역 : 종료 -->  
   			</TD>
  		</TR>
	</TABLE>
	<!-- 검색조건 영역 : 종료 -->

	<div id="sheet1_div" style="width: 970px; padding-top:5px; height: auto; min-height: 480px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '480px');</script>
	</div>
</FORM>
</body>