<%--
  - Author(s)  : 김예진
  - Date       : 2015.01.08
  - 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.udapsoft.common.code.CommCodeManager" %>
<%@ 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();

%>
<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
		 */
		$("#btnSearch").click(function() {
			jQuery("#fevent").val("SHEET_SELECT");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/stamptax/SalStampList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
		});
		$("#p_corp_name").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);if(keycode == 13)$("#btnSearch").click();});
		$("#p_cont_no").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);if(keycode == 13)$("#btnSearch").click();});
		$("#p_cont_name").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);if(keycode == 13)$("#btnSearch").click();});
		//$("#btnSearch").click();
		$("#dataClear").click(function(){$("#DutyFromDt").val("");$("#DutyToDt").val("");});
		
		jQuery("#btnExcel").click(function() {
			if(sheet1.RowCount() == 0) {
				alert("내역이 없습니다.");
				return;
			}
			var params = { FileName : "PurStampList.xls",  SheetName : "PurStampList", SheetDesign:0, Merge:1, DownCols:"STAMP_DUTY_ISSUE_GB"+            
					"|CORP_REG_NO|CORP_NAME|CONT_NO|MOD_NO|CONT_NAME|CURRENCY_GB|CONT_AMT|STAMP_DUTY_NO|STAMP_DUTY_TAX|STAMP_DUTY_DATE|REMARK", 
					TitleText:"영업_인지세현황", UserMerge:"0,0,1,12", AutoSizeColumn:1  } ;
			sheet1.Down2Excel(params);
		});
		
		//신규등록 페이지 이동 
		$("#btnNew").click(function() {
			 if(confirm("신규등록 하시겠습니까?")){
				 var win_id = "_SalStampPop";
				 var link = "/cont/stamptax/SalNewPop.screen";
				       link += "?pop_win_id="+win_id;
				       
				fLayerPop(win_id, link, 700,450, '', '', 'NO');
			 }
		});
		
		autoResize();
	}
	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:100};
		init_sheet.Cols = [
		       			{Header:'Del',				Type:"DelCheck",		SaveName:"DEL_CHECK", 			Width:50, 		Align:"Center",		Hidden:"True"},
		    			{Header:'Status',			Type:"Status", 			SaveName:"STATUS", 				Width:0, 		Align:"Center",		Hidden:"True"},
		    			{Header:'인지세ID',			Type:"Text", 			SaveName:"STAMP_DUTY_ID", 		Width:60, 		Align:"Center",		Hidden:"True"},
		    			{Header:'인지세구분',		Type:"Text", 			SaveName:"STAMP_DUTY_TYPE", 	Width:80, 		Align:"Center" , 	Hidden:"True"},
		    			{Header:'발행주체구분',		Type:"Text", 			SaveName:"STAMP_DUTY_ISSUE_GB",	Width:80, 		Align:"Center", 	Edit:"false"},
		    			{Header:'사업자등록번호',	Type:"Text", 			SaveName:"CORP_REG_NO", 		Width:100,		Align:"Center" , 	Format:"SaupNo",	Edit:"false"},
		    			{Header:'발주처',			Type:"Text", 			SaveName:"CORP_NAME", 			Width:100, 		Align:"Left" , 		Edit:"false"},
		    			{Header:'계약번호',			Type:"Text", 			SaveName:"CONT_NO", 			Width:120, 		Align:"Left" , 		Edit:"false"},
		    			{Header:'변경차수',			Type:"Text", 			SaveName:"MOD_NO", 				Width:60, 		Align:"Center" , 	Edit:"false"},
		    			{Header:'☞계약명',			Type:"Text", 			SaveName:"CONT_NAME", 			Width:150, 		Align:"Left" , 		Edit:"false",	Cursor:'pointer'},
		    			{Header:'통화',				Type:"Text", 			SaveName:"CURRENCY_GB", 		Width:60, 		Align:"Center" , 	Edit:"false"},
		    			{Header:'계약금액',			Type:"Text", 			SaveName:"CONT_AMT", 			Width:80, 		Align:"right",		Edit:"false"},
		    			{Header:'고유식별번호',		Type:"Text", 			SaveName:"STAMP_DUTY_NO", 		Width:80, 		Align:"Center",		Edit:"false"},
		    			{Header:'인지세액',			Type:"Text", 			SaveName:"STAMP_DUTY_TAX", 		Width:70, 		Align:"right", 		Edit:"false"},
		    			{Header:'발행일자',			Type:"Text", 			SaveName:"STAMP_DUTY_DATE", 	Width:70, 		Align:"center", 	Edit:"false"},
		    			{Header:'비고',				Type:"Text", 			SaveName:"REMARK", 				Width:80, 		Align:"Left",		Edit:"false"},
		]; 

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		//sheetName.SetImageList(1,"/img/buyer/button/bt_change.gif");
		sheetName.SetActionMenu("ExcelDown");
		setGridSize();
	}
	
	
	//팝업창 종료후 새로고침 위한 function
	function doSearch(){
		jQuery("#fevent").val("SHEET_SELECT");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/stamptax/SalStampList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}
	
	//팝업창에 첨부파일창 parent로 불러오기위한 function
	function doAttachStampFilePop(fileGB, obj, fObj, editFile, fileDir){
		if(obj != ''){ 
			viewFileListNew(fileGB, obj, fObj, editFile, fileDir, "_SalStampPop", "", "", "N");
		}
	}
	
	
	
	/*
	IBSheet Event : Mouse Right Menu
	*/
	function sheet1_OnSelectMenu(Text, Code) {
		  // text 또는 code값으로 Action수행
		switch(Text) {
	         case "ExcelDown":
	        	jQuery("#btnExcel").click();
	            break; 
		}
	}	
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("CONT_NAME", "#0000ff");
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 if(Row == 0)return;
		  	if (sheet1.ColSaveName(Col) == "CONT_NAME") {

				 var win_id = "_SalStampPop";
				 var p_move = "d";
				 var link = "/cont/stamptax/SalNewPop.screen";
				     link += "?pop_win_id="+win_id;
				     link += "&p_stamp_duty_id="+sheet1.GetCellValue(Row, "STAMP_DUTY_ID");
				     link += "&p_move="+p_move;
				       
				fLayerPop(win_id, link, 700, 450, '', '', 'NO');
			} 

		  /*if (sheet1.ColSaveName(Col) == "FILE_YN") {
	     		var url="/common/file/FileDownloadServlet";
	     		url += "?file_id=" + sheet1.GetCellValue(Row, "FILE_ID");
	     		
	     		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
	     		
	     		var fd = document.getElementById("form_filedown");
	     		fd.target = "_fileDown";
	     		fd.file_id.value = sheet1.GetCellValue(Row, "FILE_ID");
	     		fd.submit();
	     	} */
	 }
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {sheet1.FitColWidth();}

	//자동로그인 기능
	function f_gologin(login_id,login_pw){
		var f = document.form1;
		if('<%= user.get("ACCT_TYPE_CODE")%>' != "ADMIN"){
			dlgAlert("User who logged in as administrator only can do automatic log-in.");
			return;
		}
	
		f.login_id.value = login_id;
		f.login_pw.value = login_pw;
	
		if( !submitXmlRequest("/sign_on_check", "", document.form1) ) {
			alert("Log-in is being processed.");
		};
		
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
		
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + 24;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   
		
		sheet1.SetSheetHeight(iframeHeight); 
	}	
	document.body.onresize = addEvent( document.body.onresize, "autoResize()");
</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=p_stamp_duty_id value="">

<div align="left" id="title">
	<ul>
		<li>영업_인지세현황</li>
	</ul>
</div> 

<!-- 검색조건 시작 -->
<table id="search-table" class="search-form-table">
	<colgroup>
		<col width="100" />
		<col width="*" />
		<col width="100" />
		<col width="*" />
		<col width="200" />
	</colgroup>
  <tr height="25"> 
  	<th>발주처</th>
   	<td>
  		<INPUT type="text" name="p_corp_name" class="input" value="<%= params.get("p_corp_name") %>" style="width:90%"> 
	</td>
	<th>발행일자</th>
    <td> 
		<%= InputText.get("DutyFromDt", params.get("DutyFromDt"), 10, 50, "hangule,center, desc=계약일자,ReadOnly") %>
		<IMG name="start_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('DutyFromDt');">
					~
		<%= InputText.get("DutyToDt", params.get("DutyToDt"), 10, 50, "hangule,center, desc=계약일자,ReadOnly") %>
		<IMG name="start_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('DutyToDt');">
		<IMG name="dataClear" id="dataClear" src="/img/buyer/button/bt_eraser1.gif" border="0" align="absmiddle" style="cursor:pointer;">
    </td> 
	<td class="button" rowspan="2">
		<span class="btnSearch center" id="btnSearch"><a href="javascript:void(0);">검색</a></span>
		<span class="btnSearch center" id="btnExcel"><a href="javascript:void(0);">엑셀</a></span>
		<span class="btnSearch center" id="btnNew"><a href="javascript:void(0);">신규등록</a></span>
	</td>	
  </tr>
  <tr> 
    <th>계약번호</th>
    <td> 
       <INPUT type="text" name="p_cont_no" class="input" value="<%= params.get("p_cont_no") %>" style="width:90%"> 
    </td>
    <th>계약명</th>
   	<td>
   		<INPUT type="text" name="p_cont_name" class="input" value="<%= params.get("p_cont_name") %>" style="width:90%"> 
	</td>   
  </tr>
</table>
<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 400px; overflow: auto;">
	<script>createIBSheet('sheet1','100%', '400px');</script>
</div>
</form>
