<%--
  - Author(s)  : 김예진
  - Date       : 2015.02.01
  - Description: 외주_인지세
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.ui.InitCombo" %>
<%@ 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" /> --%>
<%

	CommCodeManager commCodeManager = new CommCodeManager();
	
	RowSet issueGbRow = CommCodeManager.getCodeRowsetStatic("STAMP_DUTY_ISSUE_GB");

	InitCombo initCombo = new InitCombo();
	initCombo.makeComboData(CommCodeManager.getCodeRowsetStatic("STAMP_DUTY_ISSUE_GB", "CHG_CODE01", "Y"), "DETAILNM", "DETAILCD");
	/* initCombo.makeComboData(commCodeManager.getCodeRowSet("STAMP_DUTY_ISSUE_GB"), "NAME", "CODE"); */
	String ISSUE_GB_CD = initCombo.getCode();
	String ISSUE_GB_NM = initCombo.getCodeName();
	
%>
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet2;
	var sheet2Row;
	var sheet2PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	/* function _onReady(){
		
	} */
	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit2(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:10};
		init_sheet.Cols = [
		       			{Header:'Del',				Type:"DelCheck",		SaveName:"DEL_CHECK", 			Width:30, 		Align:"Center"},
		    			{Header:'Status',			Type:"Status", 			SaveName:"STATUS", 				Width:0, 		Align:"Center", Hidden:"true"},
		    			{Header:'인지세ID',			Type:"Text", 			SaveName:"STAMP_DUTY_ID", 		Width:0, 		Align:"Center", Hidden:"true"},
		    			{Header:'발행주체',			Type:"Combo", 			SaveName:"STAMP_DUTY_ISSUE_GB", Width:80, 		Align:"Center",	ComboText:"<%=ISSUE_GB_NM%>", ComboCode:"<%=ISSUE_GB_CD%>"},
		    			{Header:'고유식별번호',		Type:"Text", 			SaveName:"STAMP_DUTY_NO", 		Width:80,		Align:"Center"},
		    			{Header:'인지세액',			Type:"AutoSum", 		SaveName:"STAMP_DUTY_TAX", 		Width:80, 		Align:"right"},
		    			{Header:'발행일자',			Type:"Date", 			SaveName:"STAMP_DUTY_DATE", 	Width:70, 		Align:"Center"},
		    			{Header:'비고',				Type:"Text", 			SaveName:"REMARK", 				Width:150, 		Align:"Left"},
		    			{Header:'☞사본',			Type:"Text", 			SaveName:"FILE_YN", 			Width:50, 		Align:"center", Edit:"false",	Cursor:'pointer'},
		    			{Header:'FILE_ID',			Type:"Text", 			SaveName:"FILE_ID", 			Width:0, 		Align:"center", Hidden:"true"},
		]; 

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetImageList(1,"/img/buyer/button/bt_change.gif");
		if(jQuery("#STATUS_CD").val() == '50'){
			sheet2.SetEditable(0);
		}
		//sheetName.SetActionMenu("ExcelDown");
		setGridSize2();
	}
	
	function doSearchStamp() {
		jQuery("#fevent").val("FORM_SHEET_SELECT");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/outside/StampList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 30, "");
	}
	function doSaveStamp() {
		jQuery("#fevent").val("SAVE_STAMP_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/outside/StampList_sheet.screen";
		Modular.view.IBSheet7.doSave(sheet2, url, jQuery("#form1"), false);
	}
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet2_OnSearchEnd(code, message) {
		var info = {Type: "Image"};
	
	    if(code == 0) {
	    	setGridSize2();
			sheet2.SetColFontColor("FILE_YN", "#0000ff");
			sheet2.SetCellValue(sheet2.LastRow(), "DEL_CHECK", "합  계");
	    	sheet2.SetMergeCell(sheet2.LastRow(), 0, 1, 5);
	    	
	    	for(i=1; i <= sheet2.RowCount(); i++){
				if(sheet2.GetCellValue(i, "FILE_ID")!=""){
					sheet2.InitCellProperty(i, "FILE_YN", info);
				}
			}
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	
	function sheet2_OnSaveEnd(code, msg) {
	    if(code >= 0) {
	    	if(jQuery("#save_gb").val() != 'Y'){
	    		alert("인지세가 정상적으로 처리 되었습니다.");
	    	}
	    } else {
	    	//alert(msg);
	    	alert("인지세 처리에 실패 하였습니다.");
        }
	    doSearchStamp();
	}
	
	/*
	IBSheet Event : Mouse Right Menu
	*/
	function sheet2_OnSelectMenu(Text, Code) {
		  // text 또는 code값으로 Action수행
		switch(Text) {
	         case "ExcelDown":
	        	jQuery("#btnExcel").click();
	            break; 
		}
	}	
	
	function sheet2_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 if(Row == 0)return;
		 if(sheet2.GetCellValue(Row, "STAMP_DUTY_ID")==''){
			alert("입력한 내용을 저장을 한 후 파일을 첨부할 수 있습니다.");
			return;
		 }
		 
		 var win_id = "_StampDutyPop";
			 var p_move = "M";
			 if (jQuery("#STATUS_CD").val() =='50' ){
				 var p_move = "N";
			 }
			 var link = "/cont/outside/stampDutyPop.screen";
			     link += "?pop_win_id="+win_id;
			     link += "&p_stamp_duty_id="+sheet2.GetCellValue(Row, "STAMP_DUTY_ID");
			     link += "&p_move="+p_move
			     link += "&p_cont_mod_id="+"<%=ContInfo.get("SUB_CONT_MOD_ID")%>"
			     link += "&p_issue_gb="+jQuery("#p_issue_gb").val()
			     link += "&p_who=E";
			  
		 
			fLayerPop(win_id, link, 900, 250, '', '', 'NO');
		 
		/* 2016.12.12
		    if (sheet2.ColSaveName(Col) == "FILE_YN") {
			 
			if(sheet2.GetCellValue(Row, "STAMP_DUTY_ID")=='' || sheet2.GetCellValue(Row, "STATUS")=="I" || sheet2.GetCellValue(Row, "STATUS")=="U"){
				alert("입력한 내용을 저장을 한 후 파일을 첨부할 수 있습니다.");
			}
			else{ 
				var STAMP_DUTY_ID = sheet2.GetCellValue(Row, "STAMP_DUTY_ID")
				var modify = 'Y';
				if(jQuery("#STATUS_CD").val() =='50' || jQuery("#p_issue_gb").val() == '00'){
					modify ='N'
				}
				viewFileListNew2('SUB_STAMP_DUTY', STAMP_DUTY_ID, "", modify, "cont/outside/stamp/"+STAMP_DUTY_ID, "", "", "", "N");
			} 
		
	     } */
	 }
	 
	//2016.12.12
	function stampDutyPopClose(){
		doSearchStamp();	 
	}	
	function doAttachStampFilePop(fileGB, obj, fObj, editFile, fileDir){
		if(obj != ''){ 
			viewFileListNew(fileGB, obj, fObj, editFile, fileDir, "_StampDutyPop", "", "", "N");
		}
	}	
	
	function fLayerPopClose(layerID){
		var	oNode	=	document.getElementById(layerID);
		if(oNode != null)
		{
			$('#'+layerID+ '_divcontent').empty();
			$('#'+layerID).bPopup().close();
			document.body.removeChild(oNode);
		}
		
		 if(layerID == "_stampFileList"){
			 doSearchStamp();
		 }
	 }
		 
	/**
	 *	IBSheet Event Change
	 */	
	 function sheet2_OnChange(Row, Col, Value, OldValue, RaiseFlag) { 
			if (sheet2.ColSaveName(Col) == "STAMP_DUTY_NO") {
				if(stringByteSize4UTF(sheet2.GetCellValue(Row, "STAMP_DUTY_NO")) > 50){
					alert("고유식별번호는 50자까지 입력하실 수 있습니다.");
					return;
				}
			}
			if (sheet2.ColSaveName(Col) == "REMARK") {
				if(stringByteSize4UTF(sheet2.GetCellValue(Row, "REMARK")) > 500){
					alert("비고는 500자까지 입력하실 수 있습니다.");
					return;
				}
			}
		}
	
	function stampDutyRowCheck() {
		for(i=1; i <= sheet2.RowCount(); i++){
			if(sheet2.GetCellValue(i, "STATUS")!="R"){
				alert("인지세중 저장되지 않은 행이 존재합니다.");
				return false;
			}
		}
		return true;
	} 
	
	function issue_gb_chg() {
		if(jQuery("#p_issue_gb").val()=="00"||jQuery("#p_issue_gb").val()==""){
			jQuery("#btnAdd").hide();
			//jQuery("#btnSaveStamp").hide();	
		}else{
			jQuery("#btnAdd").show();
			//jQuery("#btnSaveStamp").show();	
		}
	}
	
	function stampDesc()
	{
		var win_id = "_stampPopup";
		var link = "/cont/purchase/stampDescPopup.screen";
		    link += "?pop_win_id="+win_id;
		fLayerPop(win_id, link, 400,210, '', '', 'NO');
	}
	function downStampFile(){
		var url="/common/file/FileDownloadServlet?mode=fpDown";
		url += "&mode=fpDown";
		url += "&filePath=/userMenual";
		url += "&fileName=" + encodeURI("전자문서에_대한_인지세_납부방법_등에_관한_고시_(전문).hwp");
		url += "&fileRealName=stamp_duty.hwp";

		document.getElementById("fileDown").src=url;
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize2() {sheet2.FitColWidth();}
	
	document.body.onresize = addEvent( document.body.onresize, "setGridSize2()");
</SCRIPT>




<div class="application-info  magT10">
	<div class="application-sub-title">
		<!-- <span class="title">인지세</span><a href="javascript:stampDesc()"><IMG src='/img/buyer/button/q.gif' align="absmiddle"></a> <font color="red">※ 전자문서 계약자가 인지세무(과소) 납부시 가산세가 300% 부가됨</font> <a href="javascript:downStampFile()"><IMG src='/img/buyer/button/bt_change.gif' align="absmiddle"></a>-->
	    <span class="title">인지세<a href="javascript:downStampFile()"><IMG src='/img/buyer/button/q.gif' align="absmiddle"></a></span>&nbsp; <a href="http://www.e-revenuestamp.or.kr" target="_blank">전자수입인지사이트 바로가기(www.e-revenuestamp.or.kr)</a><font color="red">&nbsp;※ 전자문서 계약자가 인지세 무(과소)납부시 가산세가 300% 부가됨</font> <span class="btnSearch center" id="btnhelp" ><a href="javascript:stampDesc()">납부금액안내</a></span>
	</div>
</div>
<!-- 검색조건 시작 -->
<table id="search-table" class="search-form-table">
  <tr height="25"> 
  	<td>인지세 발급 구분:&nbsp;&nbsp;<%= HTMLMaker.getSelectTag(issueGbRow, "CODE", "NAME", "p_issue_gb", "style='width:100px;' onChange='issue_gb_chg();'", "", ContInfo.get("STAMP_DUTY_GB")) %></td>
	<td class="button" align="right" style="text-align: center;width: 95px">
		<span class="btnSearch center" id="btnAdd" style="display: none;"><a href="javascript:void(0);">추가</a></span>
		<%-- <%if(isViewWrite != "W"){ %> --%>
		<span class="btnSearch center" id="btnSaveStamp" ><a href="javascript:void(0);">저장</a></span>
		<%-- <%} %> --%>
	</td>	
  </tr>
</table>
<div id="sheet2_div" style="padding-top:5px; height: 157px; min-height: 157px; overflow: auto;">
<!-- <div id="sheet2_div" style="padding-top:5px; height: auto; min-height: 100px; overflow: auto;"> -->
	<script>createIBSheet('sheet2','100%', '157px');</script>
</div>
<iframe id="fileDown" name="fileDown" style="display:none"></iframe>
