<%--
  - FileName   : QuotSuppChoicePop.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.*" %>
<%@ 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 bid_kind = storage.get("BID_KIND");
	String menu = storage.get("MENU");
%>
<script type="text/javascript">
<!--
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	$(document).on("keyup", "input:text[numberOnly]", function() {$(this).val( $(this).val().replace(/[^0-9]/gi,"") );});
	
	$(document).ready(function(){
	    
		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:"CheckBox", 		SaveName:"CHECK",			Width:25, 	Align:"Center", ColMerge:"False"},
									{Header:"QUOT_REG_CORP_ID",	Type:"Text", 			SaveName:"QUOT_REG_CORP_ID",Width:100, 	Align:"Center", Edit:"False", Hidden:"True"},
									{Header:"사업자번호",			Type:"Text", 			SaveName:"CORP_REG_NO",		Width:40, 	Align:"Center", Edit:"False", Format:"SaupNo"},
									{Header:"업체명",				Type:"Text", 			SaveName:"CORP_KOR", 		Width:60, 	Align:"Left", Edit:"False", ToolTip:1},
									{Header:"의견",				Type:"Text", 			SaveName:"REMARK",	 		Width:60, 	Align:"Left", Edit:"False", ToolTip:1},
									{Header:"대표자명",			Type:"Text", 			SaveName:"REP_NAME", 		Width:50, 	Align:"Center", Edit:"False"},
									{Header:"담당자명",			Type:"Text", 			SaveName:"CHARGE_NAME", 	Width:50, 	Align:"Center", Edit:"False", ColMerge:"False"},
									{Header:"핸드폰",				Type:"Text", 			SaveName:"CHARGE_HP", 		Width:50, 	Align:"Center", Edit:"False", ColMerge:"False"},
									{Header:"구분",				Type:"Text", 			SaveName:"IN_OUT_DIV_NM", 	Width:50, 	Align:"Center", Edit:"False", ColMerge:"False"},
									{Header:"IN_OUT_DIV",		Type:"Text", 			SaveName:"IN_OUT_DIV", 		Width:50, 	Align:"Center", Edit:"False", Hidden:"True", ColMerge:"False"},
									{Header:"연락처",				Type:"Text", 			SaveName:"TEL_NUM", 		Width:50, 	Align:"Center", Edit:"False", Hidden:"True", ColMerge:"False"},
									{Header:"이메일",				Type:"Text", 			SaveName:"CHARGE_EMAIL", 			Width:60, 	Align:"Left", Edit:"False", ColMerge:"False"}
		                   		];
		
		
		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheet1, init_sheet);
		sheet1.SetDataAutoTrim(0);
// 		sheet1.SetEditable(true);
		//sheet1.SetMergeSheet(msAll);
// 		sheet1.SetMergeSheet(msPrevColumnMerge);
		sheet1.SetDataLinkMouse("CORP_REG_NO");		
		sheet1.SetDataLinkMouse("REMARK", 1);
		sheet1.SetColFontColor("REMARK", "#0000ff");
		
		sheet1.FitColWidth();
		
		var bidkind = "<%=bid_kind%>";
		var menu = "<%=menu%>";
		
		if(bidkind.length > 0){
			$("#corp_status").val(bidkind);	
			$("#corp_status").attr("disabled","disabled");
		}
		
		if(menu.length > 0){
			$("#menu_type").val(menu);			
		}
	});
	
	

	$(function(){
		
		$("#btn_search").click(function(){
			$("#fevent").val("GET_CORP_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/quot/purchase/QuotSuppChoicePop_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
		});
		
		$("#corp_no").keydown(function (event)
		{
			var keycode = (event.keyCode ? event.keyCode : event.which);
			if(keycode == 13)$("#btn_search").click();
		});
		
		$("#corp_name").keydown(function (event)
		{
			var keycode = (event.keyCode ? event.keyCode : event.which);
			if(keycode == 13)$("#btn_search").click();
		});
		
		$("#btn_close").click(function(){
		    parent.fLayerPopClose("corp");
		});
		
		
		$("#corp_status").change(function(){

		});

		
		
		
		
		$("#btn_select").click(function(){
		    
		    var len = sheet1.LastRow();
		    
		    var corp_id		= new Array;
	     	var corp_reg_no	= new Array;
	     	var corp_kor = new Array;
	     	var rep_name = new Array;
	     	var user_name = new Array;
	     	var tel_num = new Array;
	     	var h_phon = new Array;
	     	var email = new Array;
	     	var on_supp_yn = new Array;
	     	var in_out_div = new Array;
		    
	     	var idx = 0;
     	   if(len>=1)
     	   {
     	      for(var i=1; i<=len; i++)
  	    	  {
  		      	if(sheet1.GetCellValue(i,"CHECK") == "1")
  	   			{
  		            corp_id[idx] = sheet1.GetCellValue(i, "QUOT_REG_CORP_ID");
  		          	corp_reg_no[idx] = sheet1.GetCellValue(i, "CORP_REG_NO");
  		          	corp_kor[idx] = sheet1.GetCellValue(i, "CORP_KOR");
  		        	rep_name[idx] = sheet1.GetCellValue(i, "REP_NAME");
  		        	user_name[idx] = sheet1.GetCellValue(i, "CHARGE_NAME");
  		        	tel_num[idx] = sheet1.GetCellValue(i, "TEL_NUM");
  		        	h_phon[idx] = sheet1.GetCellValue(i, "CHARGE_HP");
  		        	email[idx] = sheet1.GetCellValue(i, "CHARGE_EMAIL");
  		        	on_supp_yn[idx] = "N";
  		        	in_out_div[idx] = sheet1.GetCellValue(i, "IN_OUT_DIV");
  		        	idx++;
  	   			}
  		      	
  	    	  }
     	      
     	     var returnValue = new Array(corp_id, corp_reg_no, corp_kor, rep_name, user_name, tel_num, h_phon, email, on_supp_yn,in_out_div);
     	     
//      	     parent.resultFuntion(returnValue);
				window.parent.$.test2(returnValue);
				//parent.fLayerPopClose("corp");
     	   }
		});
		
		
// 		$.test('qwe');		
	});

	
	/*
	function sheet1_OnClick(Row, Col)
	{
	    var s_name = sheet1.ColSaveName(Col);
	    alert(sheet1.GetCellValue(i,"CHECK"));
	    
	    if(s_name == "CORP_REG_NO")
	    {
	        $("#fevent").val("GET_DETAIL");
	        $("#p_corp_id").val(sheet1.GetCellValue(Row, "CORP_ID"));
	        $("#p_charge_seq").val(sheet1.GetCellValue(Row, "CHARGE_SEQ"));
	        
	        $("#form1").attr("action", "/supplier/purchase/SuppJoinRequest.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
	    }
	}
	*/
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	sheet1.FitColWidth();
	    	
	    	if($("#corp_status").val() == "P"){
	    		if($("#menu_type").val() != "QUOT"){
	    			sheet1.SetColHidden("APPR_TOT_RATE",0);
		    		sheet1.SetColHidden("VALID_BID_YN_NM",0);	
	    		}
	    	}
	    } else {
			//조회 에러 수행
			alert(message);
		}
	}

	function sheet1_OnDblClick(Row, Col, Value)
	{
		var s_name = sheet1.ColSaveName(Col);
		
		if(s_name == "REMARK") {
        	dlgAlert(sheet1.GetCellValue(Row, "REMARK"));
	    }
	}
	
	function doResult(resultObj) {
		
		try {
		    
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
//-->
</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") %>" />
<input type="hidden" name="materialgroup" id="materialgroup" value=""/>
<input type="hidden" name="menu_type" id="menu_type" value=""/>


<table border="0" cellspacing="0" cellpadding="0" width="100%" style="height: auto;">
	<!-- 검색조건 영역 : 시작 -->
	<tr>
		<td height="1">
			<table cellspacing="1" cellpadding="0" class="search-form-table">
				<col width="11%">
				<col width="15%">
				<col width="7%">
				<col width="30%">
				<col width="7%">
				<col width="7%">
				<col width="*">
				
				<tr height="25"> 
    			<!-- 검색조건 타이틀 1 -->
    				<th>
    					사업자번호
    				</th>
   					<td>
  						<input type="text" name="corp_no" id="corp_no" maxlength="10" numberOnly="true" style="width: 90%;" value=""/>
					</td>
    				<th>
        				검색어
    				</th>
    				<td>
    					<select name="search_gb" id="search_gb" style="width: 29%; height=18;">							
							<option value="2">업체명</option>
							<option value="1">업체명+의견</option>
							<option value="3">의견</option>
						</select>    				
    					<input type="text" name="corp_name" id="corp_name" style="width: 59%;"  value=""/>
    				</td>
    				<th>
	        			구분
	    			</th>
    				<td>
      				<select name="IN_OUT_DIV" id="IN_OUT_DIV" style="width: 103px;">
      		   					<option value="">전체</option>
		      					<option value="I">국내</option>
		      					<option value="O">국외</option>
		      				</select>
    				</td>
				    <td rowspan="3" 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_select">선택</a></span>
			         	<!-- <span class="btnSearch center"><a href="javascript:void(0);" id="btn_close">닫기</a></span> -->
            			<!-- 검색버튼 영역 : 종료 -->  
    				</td>
  				</tr>

  				<!-- <tr height="25"> 
    				검색조건 타이틀 1
    			</tr> -->
			</table>
		</td>
	</tr>
	<!-- 검색조건 영역 : 종료 -->

	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
	<tr>
		<td height="1">
			<table border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
				<tr>
					<td>
					</td>				
				</tr>
			</table>
		</td>
	</tr>
</table>
</form>

<div style="width: 100%;">
	<!-- 데이터 영역 : 시작 -->
	<!-- ibsheet7 그리드 생성 -->
		<script>createIBSheet("sheet1","100%", "300px");</script>
	<!-- 데이터 영역 : 종료 -->
</div>


	