<%--
  - FileName   : resolutionRequestList.jsp
  - Author(s)  : ok
  - Date       : 2014.06.30
  - Copyright  : Copyright (c) 2013 www.udapsoft.co.kr, Inc.
  - Description: 협력업체포탈 기성신청현황-2019.04.24 
--%>

<%@ 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();
    
    RowSet statusComboList = storage.getRowSet("statusComboList"); //상태 ComboList Data
  	
    String  returnAcmpYyyymm = params.get("acmpYyyymm");
    String  returnBuildName = params.get("searchBuildName");
    String  returnDeptName = params.get("searchDeptName");
    String  returnStatusCd = params.get("searchStatusCd");
    
    //초기 상태값 설정
    if(returnStatusCd == null || returnStatusCd == ""){
    	returnStatusCd = "00";
    }

%>
<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);
		
		autoResize();
	
		/**
		 *	Application Initialize
		 */
		jQuery("#btnSearch").click(function() {
			
 			jQuery("#fevent").val("GET_DATA");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/payment/ResolutionRequestList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, ""); 
			 
		});
		
		jQuery("#btnCreate").click(function() {
			
			var win_id = "ApplicationRequest";
			var link = "/portal/payment/ApplicationRequestList.screen";
			    link += "?pop_win_id="+win_id;
			    link += "&searchDate=" + jQuery("#searchDate").val();
			    link += "&userCorpId=" + jQuery("#userCorpId").val();
			    //link += "&{{query}}";
			fLayerPop(win_id, link, 980, 540, '', '', 'NO');
			
		});
		
		pageinit();
		
	}
	
	function pageinit(){
		
		setSearchDate();
		
		jQuery("#btnSearch").click();
		
	}
	
	/**
	 *	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:"Text", 			SaveName:"DEPT_NAME",			Width:130, 	Align:"Left"},
		    			{Header:'☞계약명|☞계약명',			Type:"Text", 			SaveName:"BUILD_NAME",			Width:130, 	Align:"Left"},
		    			{Header:'공사기간|공사기간',			Type:"Text", 			SaveName:"START_END_WORK_DATE", Width:80, 	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:"FUND_RATE",	 		Width:30, 	Align:"Right"},
		    			{Header:'상태|상태',					Type:"Text", 			SaveName:"STATUS_NM", 			Width:50, 	Align:"Center"},
		    			{Header:'STATUS_CD',				Type:"Text", 			SaveName:"STATUS_CD", 			Width:50, 	Align:"Center", Hidden:"True"},
		    			{Header:'SUB_CONT_ID',				Type:"Text", 			SaveName:"SUB_CONT_ID", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'ACMP_YYYYMM',				Type:"Text", 			SaveName:"ACMP_YYYYMM", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'CON_CORP_ID',				Type:"Text", 			SaveName:"CON_CORP_ID", 		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'SUB_CONT_MOD_ID',			Type:"Text", 			SaveName:"SUB_CONT_MOD_ID",		Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'MOD_NO',					Type:"Text", 			SaveName:"MOD_NO",				Width:0, 	Align:"Center", Hidden:"True"},
		    			{Header:'ACMP_ID',					Type:"Text", 			SaveName:"ACMP_ID", 			Width:0, 	Align:"Center", Hidden:"True"}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		sheetName.SetDataLinkMouse("BUILD_NAME", 1);
		
		setGridSize();
	}

	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("BUILD_NAME", "#0000ff");
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	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_NAME") {	//계약명

 			jQuery("#selectSubContId").val(sheet1.GetCellValue(Row, "SUB_CONT_ID"));	//외주계약서ID
 			jQuery("#selectSubContModId").val(sheet1.GetCellValue(Row, "SUB_CONT_MOD_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 setSearchDate(){
	    
		var newDay = new Date( get_year(), get_month(), "");
	    var lastDay = newDay.getDate();
	    var yyyymm = get_year() +'-'+ get_month();
	    
	    if(jQuery('#searchDate').val() == ""){
	    	jQuery('#searchDate').val(yyyymm);	
	    }
    		
	}

	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}
	
	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight  + document.getElementById("bugase").scrollHeight + document.getElementById("title").scrollHeight + 54;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   
		
		
		sheet1.SetSheetHeight(iframeHeight); 
	}	
	
	function callback_getData(){
		setTimeout(function(){fLayerPopClose('ApplicationRequest');},100);
		jQuery("#btnSearch").click();
	}
	
</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="selectSubContId" id="selectSubContId" value="">
<INPUT type="hidden" name="selectSubContModId" id="selectSubContModId" value="">
<INPUT type="hidden" name="acmpId" id="acmpId" value="">
<INPUT type="hidden" name="acmpYyyymm" id="acmpYyyymm" value="">
<INPUT type="hidden" name="conCorpId" id="conCorpId" value="">
<INPUT type="hidden" name="acmpNo" id="acmpNo" value="">
<INPUT type="hidden" name="userCorpId" id="userCorpId" value="<%=user.get("CORP_ID")%>">
	
	<!-- 프로그램 제목 -->
	<div align="left" id="title">
		<ul>
			<li>외주_기성현황</li>
		</ul>
	</div> 	
	
	<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="10%" />
			<col width="20%" />
			<col width="10%" />
			<col width="*" />
			<col width="15%" />
		</colgroup>
		<tr>
			<th>계약명</th>
			<td><INPUT type="text" id="buildName" name="buildName" value="<%=returnBuildName %>" maxlength="50" class="input" style="IME-MODE : active; width:90%;"  desc='계약명' onKeyPress="doKeyPress();"></td>
			<th>기성년월</th>
			<td>
				<%= InputText.get("searchDate", returnAcmpYyyymm, 30, 10, "Center, date, PerSize, readonly", "date", "") %>
				<a href="JavaScript:calendar('searchDate');"><img src="/img/supplier/template/bt_calender.gif" alt="달력" border="0" align="absmiddle" /></a>
			</td>
			<td class="button" rowspan="2">
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">검색</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnCreate">신규기성작성</a></span>
			</td>
		</tr>
		<tr>
			<th>현장명</th>
			<td><INPUT type="text" id="deptName" name="deptName" value="<%=returnDeptName %>" maxlength="50" class="input" style="IME-MODE : active; width:90%;"  desc='계약명' onKeyPress="doKeyPress();"></td>
			<th>상태</th>
			<td>
				<%= HTMLMaker.getSelectTag(statusComboList, "DETAILCD", "DETAILNM", "detailcd", "width:45%;height=18;", "<option value=''>전체</option>", returnStatusCd) %>
			</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:5px; height: auto; min-height: 350px; overflow: auto;">
		<SCRIPT>
			createIBSheet('sheet1','100%', '350px');
		</SCRIPT>
	</div>
</FORM>
