<%--
  - FileName   : PuSupplierPlanApprList.jsp
  - Author(s)  : Sung Min Lee
  - Date       : 2014.06.17
  -
  - 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.util.DateUtil"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig"%>
<%@ 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 defaultDS = WAFConfig.get("waf.sql.Default.DS");

	//검색조건 현장 설정
  	String initSearchDeptCd = params.get("searchDeptCd");
  	String initSearchDeptNm = params.get("searchDeptNm");
   
  	String sToday = DateUtil.getSystemDate().substring(0,8);
%>
<script type="text/javascript" src="/js/creditEvaluationPop.js"></script>
<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();
        }
	    
	});
	
	
	$.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:0, 	Align:"Center", Hidden:"True"},
			    			{Header:"현장명",				Type:"Text", 			SaveName:"DEPT_NAME",						Width:100, 	Align:"Left"},
			    			{Header:"현장코드",			Type:"Text", 			SaveName:"DEPT_CD",							Width:0, 	Align:"Left", Hidden:"True"},
	 		    			{Header:"계약번호",			Type:"Text", 			SaveName:"ORD_DOC_NO"	, 					Width:110, 	Align:"Center"},
			    			{Header:"☞계약명",			Type:"Text", 			SaveName:"CST_DOC_NAME",	 				Width:150, 	Align:"Left"},
			    			{Header:"업체명",				Type:"Text", 			SaveName:"MEMBER_NAME", 					Width:150, 	Align:"Left"},
			    			{Header:"지급구분",			Type:"Text", 			SaveName:"DEPOSIT_NM", 						Width:100, 	Align:"Center"},
			    			{Header:"평가자",				Type:"Text", 			SaveName:"WRITE_NM", 						Width:80, 	Align:"Center"},
			    			{Header:"평가점수",			Type:"Text", 			SaveName:"APPR_TOT_RATE",					Width:60, 	Align:"Center"},			    			
			    			{Header:"평가일",				Type:"Text", 			SaveName:"APPR_DY",							Width:80, 	Align:"Center"},			    			
			    			{Header:"종합평가",			Type:"Text", 			SaveName:"ITEM_STD_CD",						Width:180, 	Align:"Left"},
			    			{Header:"상태코드",			Type:"Text", 			SaveName:"PLAN_APPR_STATUS",				Width:100, 	Align:"Center", Hidden:"True"},
			    			{Header:"상태",				Type:"Text", 			SaveName:"PLAN_APPR_STATUS_NM",				Width:60, 	Align:"Center"},
			    			{Header:"평가의견",			Type:"Text", 			SaveName:"APPR_NOTE",						Width:150, 	Align:"Center"},
			    			{Header:"PUR_CONT_ID",		Type:"Text", 			SaveName:"PUR_CONT_ID", 					Width:100, 	Align:"Center", Hidden:"True"},
			    			{Header:"PAYREQ_ID",		Type:"Text", 			SaveName:"PAYREQ_ID", 						Width:100, 	Align:"Center", Hidden:"True"},			    			
			    			{Header:"CORP_ID",			Type:"Text", 			SaveName:"CORP_ID",							Width:0,	Align:"Center",	Hidden:"True"},
			    			{Header:"PLAN_APPR_CHK_EMPNO",			Type:"Text", 			SaveName:"PLAN_APPR_CHK_EMPNO",							Width:0,	Align:"Center",	Hidden:"True"}
			];
		
		
		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		
		sheetName.FitColWidth();
		
		sheet1.SetDataLinkMouse("CST_DOC_NAME", 1);
		sheet1.SetColFontColor("CST_DOC_NAME", "#0000ff");
		
// 		var obj = { Format: "Ymd", X:300, Y:600, CallBack: "Test" };
		
	}
	
	
	
	$(function(){
	    
	    $.searchList = function()
		{
			$("#fevent").val("GET_LIST");
			
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/payment/purchase/PuSupplierPlanApprList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
		}
	    
	    
	    $("#btn_search").click(function(){
		    $.searchList();
		});
	    
	    /* $("#btn_excel").click(function(){
	        var params = {FileName:"협력업체 평가현황.xls",SheetName:"협력업체 평가현황",Merge:1,SheetDesign:1, HiddenColumn:1};
	        sheet1.Down2Excel (params);
	    }); */
		
	});
	
	
	
	$(document).ready(function(){
		setSearchDate();
	    $.gridInit(sheet1);
		//$.searchList();
		
		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 setSearchDate(){
	    
		var newDay = new Date( get_year(), get_month(), "");
	    var lastDay = newDay.getDate();
	    //var yyyymmbeginning = get_year() +'-'+ get_month() +'-'+ '01';
	    //var yyyymmlast	= get_year() +'-'+ get_month() +'-'+ lastDay;
	    var searchFromDate = get_year() +'-'+ '01';
	    var searchToDate   = get_year() +'-'+ get_month();
	    
	    jQuery('#searchFromDate').val(searchFromDate);
	    jQuery('#searchToDate').val(searchToDate);

	}
	 
	function doResult(resultObj) {
	    
		try {
		    
			if ( resultObj.getRequestEvent() == "GET_MATL_KIND_CODE_LV2" ) 
			{
				if ( resultObj.getSuccess() == true ) 
				{
				   
					
				} else {
                    dlgErrorMsg(resultObj);
                }
			}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		var f = document.form1;
		if (sheet1.ColSaveName(Col) == "APPR_TOT_RATE") {
	        var reportInfo = new ReportInfo();
	        
	        
	        if(sheet1.GetCellValue(Row, "APPR_TOT_RATE").trim() != "")
            {
		        if(sheet1.GetCellValue(Row, "DOC_CD") == "03")
	            {
		            reportInfo.title = "기자재공급업체 현장평가표(Manufacturer)";
		            if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2014")
		            {	reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport3.mrd";}
		            else if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2016")
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport3_2016.mrd";}
		            else if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2019")
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport3_2019.mrd";}		            
		            else
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport3_2020.mrd";}	
		            reportInfo.set(sheet1.GetCellValue(Row, "CORP_ID"));    	// $1
			        reportInfo.set(sheet1.GetCellValue(Row, "ARR_ID"));    	// $2
			        reportInfo.set(sheet1.GetCellValue(Row, "DOC_CD"));    	// $3
			        reportInfo.set(sheet1.GetCellValue(Row, "APPR_DY").substring(0,4)); 
	            }
		        else if(sheet1.GetCellValue(Row, "DOC_CD") == "04")
	            {
		            reportInfo.title = "기자재공급업체 현장평가표(Agent)";
		            if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2014")
		            {	reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport4.mrd";}
		            else if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2016")
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport4_2016.mrd";}
		            else if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2019")
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport4_2019.mrd";}		            
		            else
		            {  reportInfo.reportName = "/report/mrd/buyer/supplier/purchase/PuSupplierReport4_2020.mrd";}
		            reportInfo.set(sheet1.GetCellValue(Row, "CORP_ID"));    	// $1
			        reportInfo.set(sheet1.GetCellValue(Row, "ARR_ID"));    	// $2
			        reportInfo.set(sheet1.GetCellValue(Row, "DOC_CD"));    	// $3
			        reportInfo.set(sheet1.GetCellValue(Row, "APPR_DY").substring(0,4));
	            }
		        
		        reportInfo.width = 1000;                         	// Default: 1024
		        reportInfo.height = 700;                         	// Default: 768
//	 	        reportInfo.reportOption = "/rf /rsn ["+f.defaultDS.value+"]"; 	             	// Default: '/rf'

		        
		        reportInfo.showPopup();
            }
		}
		else if (sheet1.ColSaveName(Col) == "CST_DOC_NAME"){
			var p_payreq_id = sheet1.GetCellValue(Row, "PAYREQ_ID");
		    var p_corp_id = sheet1.GetCellValue(Row, "CORP_ID");
		    var p_dept_cd = sheet1.GetCellValue(Row, "DEPT_CD");
		    var p_ord_doc_no = sheet1.GetCellValue(Row, "ORD_DOC_NO");
		    var p_pur_cont_id = sheet1.GetCellValue(Row, "PUR_CONT_ID");
		    var p_user_sabun = "<%=user.get("USER_SABUN")%>";
		    var p_status = sheet1.GetCellValue(Row, "REGU_STATUS_CD");
		    var p_plan_appr_status = sheet1.GetCellValue(Row, "PLAN_APPR_STATUS");
		    var p_plan_appr_chk_empno = sheet1.GetCellValue(Row, "PLAN_APPR_CHK_EMPNO");
		    
		    var argObj = new Object();
		    argObj.p_payreq_id = p_payreq_id;
		    argObj.p_plan_appr_status = p_plan_appr_status;
		    argObj.p_plan_appr_chk_empno = p_plan_appr_chk_empno;
		    argObj.p_corp_id = p_corp_id;
		    argObj.p_dept_cd = p_dept_cd;
		    argObj.p_ord_doc_no = p_ord_doc_no;
		    argObj.p_pur_cont_id = p_pur_cont_id;
		    argObj.p_user_sabun = p_user_sabun;
		    argObj.P_CHARGE_CD = "C";
		    
		    argObj.title = '설계 평가표 생성';
		    
		    /*var dialogHeight = 900;
			if(sheet1.GetCellValue(Row, "ADM_YEAR") == "2020"){  
				dialogHeight = 500;
			} */ 					
			var url = "/payment/purchase/PuSuppPlanApprPop.screen?p_corp_id="+p_corp_id+"&p_dept_cd="+p_dept_cd+"&p_pur_cont_id="+p_pur_cont_id+"&p_user_sabun="+p_user_sabun+"&p_status="+p_status+"&p_payreq_id="+p_payreq_id+"&p_plan_appr_status="+p_plan_appr_status+"&p_plan_appr_chk_empno="+p_plan_appr_chk_empno+"&P_CHARGE_CD=C&sModule=LM";
			var win_id = "PlanApprPop";			
			//result = window.showModalDialog(url, argObj,'dialogWidth:800px;dialogHeight:' + dialogHeight + 'px; center:yes; help:no; status:no; scroll:yes; resizable:no');
			//$.searchList();
			result = fLayerPop(win_id, url, 800 ,900, '', '', 'NO');			
			
		}
	 }
	 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="materialgroup" id="materialgroup" value=""/>
<INPUT type="hidden" name="p_corp_reg_no" id="p_corp_reg_no" value="" />

<div align="left" id="title">
	<ul>
    	<li>구매_기자재 공급업체 설계평가 현황</li>
   	</ul>
</div>

<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" id="search-table">
	<!-- 검색조건 영역 : 시작 -->
	<tr>
		<td height="1">
			<table cellspacing="1" cellpadding="0" class="search-form-table">
				<col width="10%">
				<col width="30%">
				<col width="10%">
				<col width="30%">
				<col width="20%">
				
				<tr height="25"> 
    			<!-- 검색조건 타이틀 1 -->
    				<th>
    					현장명
    				</th>
   					<td>
   						<%=InputText.getSiteCodeNew("searchDeptCd", "searchDeptNm", "", user, initSearchDeptCd, initSearchDeptNm)%>
					</td>
    				<th>
        				계약명
    				</th>
    				<td>
    					<input type="text" name="build_name" id="build_name" style="width: 86%;" value="<%=params.get("build_name")%>"/>
    				</td>
				    <td rowspan="2" class="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_excel">엑셀</a></span> -->
            			<!-- 검색버튼 영역 : 종료 -->  
    				</td>
  				</tr>

  				<tr height="25"> 
    				<!-- 검색조건 타이틀 1 -->
	    			<th>
	        			업체명
	    			</th>
    				<td >
      					<input type="text" name="corp_kor" id="corp_kor" style="width: 70%;"  value="<%=params.get("corp_kor")%>"/>
    				</td>
    				<th>
        				상태
    				</th>
    				<td>
  						<select name="plan_appr_status" id="plan_appr_status" style="width: 30%;" class="input_select" height=18>
  							<option value="">--전체--</option>
  							<option value="00" >평가대상</option>
  							<option value="01" >작성중</option>
  							<option value="02" >평가완료</option>
  						</select>
					</td>
    				<%-- <th>평가년월
    				</th>
    				<TD>
		   				<%= InputText.get("searchFromDate", "", 10, 50, "hangule,center, desc=평가년월, ReadOnly") %>
						<IMG name="start_img" id="calender_from" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgMCalendar('searchFromDate');">
						~
						<%= InputText.get("searchToDate", "", 10, 50, "hangule,center, desc=평가년월, ReadOnly") %>
						<IMG name="start_img" id="calender_to" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgMCalendar('searchToDate');">
		    		</TD> --%>
		    	</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>

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

</form>

