<%--
  - FileName   : QuotPurSuppRegList.jsp
  - Author(s)  : Hoon Seok Choi
  - Date       : 2023.11
  -
  - Description: 견적용 협력업체 목록
  --%>
  


<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.InitCombo" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ 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();
    
    String job_gubun = "";
    
    if(params.get("job_div").equals("P"))
    {
        job_gubun = "구매";
    }
    else
    {
        job_gubun = "외주";
    }
    
    
    //RowSet suppStatusRowSet = storage.getRowSet("SuppStatusRowSet"); //상태값
            
	//공통코드
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();
   
%>
<script language="javascript">
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	$(document).on("keyup", "input:text", function(e) {
	    if($(this).attr("numberOnly") == "true")
        {
	        $(this).val( $(this).val().replace(/[^0-9]/gi,"") );
        }
	    
	    if (e.keyCode == 13)
        {
	        $.searchList();
        }
	    
	});
	
	
	$(function(){
		
		$("#btn_reg").click(function(){
			$("#fevent").val("QUOT_REG_SUPP");
			
			$("#form1").attr("action", "/quot/purchase/QuotPurSuppReg.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		});
		
		$("#btn_search").click(function(){
			$.searchList();
		});

		
		$("#popTest").click(function(){
		    
			var win_id = "corp";			
			var link = "/common/corp/SuppChoicePop.screen";
// 			 link += "?pop_win_id="+win_id;
			fLayerPop(win_id, link, 800,400, '', '', 'NO');

		});
		
		
		$("#btn_delete").click(function(){
		    
 			$("#fevent").val("DELETE_DATA");                
 			
 			
		    if(confirm("삭제 하시겠습니까?"))
	        {
		        var url = Modular.model.PageContext.CONTEXT_ROOT + "/quot/purchase/QuotPurSuppRegList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);
	        }
		    
		});
		
		
		$.test = function(resultVal)
		{
		 	for(var i=0; i < resultVal[0].length; i++)
			{
		 	    alert(resultVal[0][i]);
		 	  	alert(resultVal[1][i]);
		 	  	alert(resultVal[2][i]);
		 	  	alert(resultVal[3][i]);
		 	  	alert(resultVal[4][i]);
		 	  	alert(resultVal[5][i]);
		 	  	alert(resultVal[6][i]);
		 	  	alert(resultVal[7][i]);
			}
		};
		
		
		$.searchList = function()
		{
			$("#fevent").val("GET_LIST");
			
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/quot/purchase/QuotPurSuppRegList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
		}
		
		
		
		
		$.gridInit = function(sheetName)
		{
		    var init_sheet = {};
			
			init_sheet.Cfg = {SearchMode:2, Page:30, MergeSheet:msHeaderOnly};
			init_sheet.Cols = [
										{Header:"Status",			Type:"Status", 			SaveName:"STATUS", 			Width:10, 	Align:"Center", Hidden:"True"},
										{Header:"선택",				Type:"DelCheck", 		SaveName:"DEL_CHK", 		Width:20, 	Align:"Center", Edit:"True"},
										{Header:"번호",				Type:"Seq", 			SaveName:"NO",				Width:20, 	Align:"Center", Edit:"False"},
										{Header:"사업자번호",			Type:"Text", 			SaveName:"CORP_REG_NO",		Width:40, 	Align:"Center", Edit:"False", Format:"SaupNo"},
										{Header:"☞업체명",			Type:"Text", 			SaveName:"CORP_KOR", 		Width:150, 	Align:"Left", 	Edit:"False"},
										{Header:"대표자명",			Type:"Text", 			SaveName:"REP_NAME", 		Width:50, 	Align:"Center", Edit:"False"},
										{Header:"담당자명",			Type:"Text", 			SaveName:"CHARGE_NAME", 	Width:50, 	Align:"Center", Edit:"False"},
										{Header:"연락처",				Type:"Text", 			SaveName:"CHARGE_HP", 		Width:50, 	Align:"Center", Edit:"False"},
										{Header:"이메일",				Type:"Text", 			SaveName:"CHARGE_EMAIL", 	Width:50, 	Align:"Center", Edit:"False"},
										{Header:"구분",				Type:"Text", 			SaveName:"IN_OUT_DIV_NM", 	Width:50, 	Align:"Center", Edit:"False"},
// 										{Header:"사업자구분",			Type:"Text", 			SaveName:"CORP_DIV_CD", 	Width:60, 	Align:"Center", Edit:"False"},
										{Header:"상태",				Type:"Text", 			SaveName:"STATUS_CD", 		Width:60, 	Align:"Center", Hidden:"True", Edit:"False"},
										{Header:"상태",				Type:"Text", 			SaveName:"STATUS_NM", 		Width:60, 	Align:"Center", Edit:"False"},
										{Header:"QUOT_REG_CORP_ID",	Type:"Text", 			SaveName:"QUOT_REG_CORP_ID",Width:100, 	Align:"Center", Hidden:"True"}
			                   		];
			init_sheet.HeaderMode = {Sort:1};
			IBS_InitSheet(sheetName, init_sheet);
			sheetName.SetDataAutoTrim(0);
// 			sheetName.SetEditable(false);
			sheetName.SetDataLinkMouse("CORP_KOR", 1);
			sheetName.SetColFontColor("CORP_KOR", "#0000ff");
			sheetName.FitColWidth();
		}
	});

	
	$(document).ready(function(){
		
	    $.gridInit(sheet1);
		$.searchList();
		
		autoResize();
		
	});
	
	
	
	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); 
	}	
	
	
	function sheet1_OnDblClick(Row, Col)
	{
	    var s_name = sheet1.ColSaveName(Col);
	    
	    if(s_name == "CORP_KOR")
	    {
	        $("#fevent").val("GET_DETAIL");
	        $("#p_corp_id").val(sheet1.GetCellValue(Row, "QUOT_REG_CORP_ID"));
	        
	        $("#form1").attr("action", "/quot/purchase/QuotPurSuppReg.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
	    }
	}
	
	function sheet1_OnSearchEnd(Row, Col)
	{
	    sheet1.FitColWidth();
	}
	
	function sheet1_OnSaveEnd(code, msg)
	{
	    var event = $("#fevent").val();
		var f = document.form1;
		
		document.form1.isSubmit = false;
		
		if(event == "DELETE_DATA")
		{
		    if(code >= "0")
			{
				alert("삭제되었습니다.");
				$("#btn_search").click();
			}
			else
			{
				alert("삭제에 실패하였습니다. 관리자에게 문의하시기 바랍니다.");
			}
		}
	}
	
	
	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_corp_id" id="p_corp_id" value="" />
<input type="hidden" name="p_charge_seq" id="p_charge_seq" value="" />
<input type="hidden" name="job_div" id="job_div" value="<%=params.get("job_div") %>" />


<div align="left" id="title">
	<ul>
    	<li><%=job_gubun %>_견적용 협력업체 관리 <!-- <a href="#" id="popTest">dsadsadasdasdasdsa</a> --></li>
   	</ul>
</div>  
 
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="search-table">
	<!-- 검색조건 영역 : 시작 -->
	<tr>
		<td height="1">
			<table cellspacing="1" cellpadding="0" class="search-form-table">
				<col width="100"/>
				<col/>
				<col width="100"/>
				<col/>
				<col width="100"/>
				<col/>
				<col width="300"/>
				
				<tr height="25"> 
    			<!-- 검색조건 타이틀 1 -->
    				<th>
    					사업자번호
    				</th>
   					<td>
  						<input type="text" name="corp_no" id="corp_no" SIZE="10" value="<%=params.get("corp_no") %>" numberOnly="true" maxlength="10" />
					</td>
    				<th>
        				업체명
    				</th>
    				<td>
    					<input type="text" name="corp_name" id="corp_name" style="width: 85%;IME-MODE : active;"  value="<%=params.get("corp_name") %>" />
    				</td>
    				<th>
	        			상태
	    			</th>
    				<td>
    					<%=CommCodeManager.getSelectCodeSearchList("QUOT_SUPP_REG_STATUS","corp_status","height=18;width:80px;","<option value=''>--전체--</option>",params.get("corp_status"),"","DETAILCD") %>
    				</td>
				    <td class="search_button" style="text-align: center;"> 
				    	<span class="btnSearch center"><a href="javascript:void(0);" id="btn_search">검색</a></span>
       					<span class="btnSearch center"><a href="javascript:void(0);" id="btn_reg">신규등록</a></span>
       					<span class="btnSearch center"><a href="javascript:void(0);" id="btn_delete">삭제</a></span>
    				</td>
  				</tr>
			</table>
		</td>
	</tr>
	<!-- 검색조건 영역 : 종료 -->

	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
	<tr>
		<td height="1">
		</td>
	</tr>
	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 종료 -->
</table>

<div id="sheet1_div" style="padding-top:5px; height: 400px">
	<script>createIBSheet("sheet1","100%", "400px");</script>
</div>

</form>

		

	