<%--
  - Author(s)  : Hoonseok Choi
  - Date       : 2023.02.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="com.udapsoft.waf.common.ui.InitCombo" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ 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();
    
	//공통코드
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();
%>
<script language="javascript" src="/js/popup.js"></script>
<SCRIPT language="JavaScript">
document.body.onresize = addEvent( document.body.onresize, "autoResize()");
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	function _onReady(){
		/**
		 *	IBSheet object initialize
		 */
		gridInit(sheet1);
		
		
		autoResize();
		/**
		 *	Application Initialize
		 */
		$("#btnSearch").click(function() {
			jQuery("#fevent").val("SHEET_SELECT");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/quot/QuotResultList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
		});
		
		$("#p_quot_bid_from_dt").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);	if(keycode == 8||keycode == 46){$("#p_quot_bid_from_dt").val("");}});
		$("#p_quot_bid_to_dt").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);	if(keycode == 8||keycode == 46){$("#p_quot_bid_to_dt").val("");}});
		$("#P_QUOT_BID_MASTER_NM").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);if(keycode == 13)$("#btnSearch").click();});
		$("#btnSearch").click();
		
		//견적제출일 To
		$("#p_quot_bid_to_dt").change(function() {
			if($("#p_quot_bid_from_dt").val().length > 0){	
				if($("#p_quot_bid_to_dt").val() <= $("#p_quot_bid_from_dt").val()){
					alert("시작 또는 종료(마감) 일시가 잘못 입력되었습니다.");
					$("#p_quot_bid_to_dt").val("");
					return;
				}
			}
		});
		
		//견적제출일 form
		$("#p_quot_bid_from_dt").change(function() {
			if($("#p_quot_bid_to_dt").val().length > 0){	
				if($("#p_quot_bid_from_dt").val() >= $("#p_quot_bid_to_dt").val()){
					alert("시작 또는 종료(마감) 일시가 잘못 입력되었습니다.");
					$("#p_quot_bid_from_dt").val("");
					return;
				}
			}
		});
		
		$("#dataClear1").click(function(){$("#p_quot_bid_from_dt").val("");$("#p_quot_bid_to_dt").val("");});
	}
	

	
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		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:'No.',				Type:"Seq", 			SaveName:"NO",					Width:0, 		Align:"Center",		Hidden:"True"},
		    			{Header:'quot_id',			Type:"Text", 			SaveName:"QUOT_ID", 			Width:200, 		Align:"Left", 		Hidden:"True"},
		    			{Header:'견적번호',			Type:"Text", 			SaveName:"QUOT_BID_NO", 		Width:120,		Align:"Center"},
		    			{Header:'차수',				Type:"Text", 			SaveName:"QUOT_BID_DEG", 		Width:30,		Align:"Center"},
		    			{Header:'현장',				Type:"Text", 			SaveName:"DEPT_NM", 			Width:200, 		Align:"Left"},
		    			{Header:'☞견적명',			Type:"Text", 			SaveName:"QUOT_BID_MASTER_NM", 	Width:200, 		Align:"Left",		Cursor:"pointer"},
		    			{Header:'견적제출마감일시',	Type:"Text", 			SaveName:"QUOT_BID_TO_DT", 		Width:120, 		Align:"Center"},
		    			{Header:'최종견적제출일시',	Type:"Text", 			SaveName:"SUBMIT_DT", 			Width:120,		Align:"Center"},
		    			{Header:'견적제출여부',		Type:"Text", 			SaveName:"SUBMIT_YN", 			Width:120,		Align:"Center"},
		    			{Header:'상태',				Type:"Text", 			SaveName:"SUPP_STATUS_NM",		Width:50, 		Align:"Center"}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		sheetName.SetActionMenu("ExcelDown");
		setGridSize();
	}

	function sheet1_OnSelectMenu(Text, Code) {
		  // text 또는 code값으로 Action수행
		switch(Text) {
	         case "ExcelDown":
	        	sheetExcelDown(sheet1,$('li').html());
	            break; 
		}
	}
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	var rowcnt = sheet1.RowCount();
	    	
	    	sheet1.SetColFontColor("QUOT_BID_MASTER_NM", "#0000ff");
			if(rowcnt> 0){
				for(var r=0; r < rowcnt; r++)
				{
					if(sheet1.GetCellValue(r+1,"SUBMIT_DT") == "미제출"){
						sheet1.SetCellFont("FontColor", r+1, 9, r+1, 9, "blue");
					}
					if(sheet1.GetCellValue(r+1,"SUBMIT_YN") == "가능"){
						sheet1.SetCellFont("FontColor", r+1, 10, r+1, 10, "red");
					}
				}
			}
			
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {

	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {sheet1.FitColWidth();}
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		if(Row == 0)return;
		if (Col == 7) {
			$("#QUOT_BID_NO").val(sheet1.GetCellValue(Row, "QUOT_BID_NO"));
			$("#QUOT_BID_DEG").val(sheet1.GetCellValue(Row, "QUOT_BID_DEG"));
			$("#QUOT_ID").val(sheet1.GetCellValue(Row, "QUOT_ID"));
			$("#STATUS_CD").val(sheet1.GetCellValue(Row, "STATUS_CD"));
			$("#fevent").val("GET_QUOT_DETAIL");
			$("#form1").attr("action", "/portal/quot/QuotResult.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		}
	 }

	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 popSearchCodeDetail(bcd)
	{
		var win_id = "_searchCodePopup";
		var link = "/sycs/code/dlgCodePopup.screen";
		    link += "?pop_win_id="+win_id;
		    link += "&p_basecd="+bcd;
		    link += "&p_search=Y";
		fLayerPop(win_id, link, 600,400, '', '', 'NO');

	}
	
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<TABLE id="t1" border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">

<TR><TD height="1">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="QUOT_BID_NO" value="">
<INPUT type="hidden" name="QUOT_BID_DEG" value="">
<INPUT type="hidden" name="QUOT_ID" id="QUOT_ID" value="">
<INPUT type='hidden' name="acct_id" value="<%= params.get("acct_id") %>">
<INPUT type="hidden" name="VENDOR_CD" value="<%=user.get("CORP_ID")%>">

<INPUT type="hidden" name="j_usertype" value="head">
<input type='hidden' name='login_id' >
<input type='hidden' name='login_pw' >
<INPUT type="hidden" name="j_admin_login_gb" value="Y">

<div align="left" id="title" >
    <ul><li>견적 현황 리스트</li></ul>
</div> 

</TD></TR>

<!-- 검색조건 영역 : 시작 -->
<TR><TD height="1">

<TR><TD height="1">
	<!-- 검색조건 시작 -->
		<table id="search-table" class="search-form-table" >
		<colgroup>
			<col width="100" />
			<col/>
			<col width="100" />
			<col/>
			<col width="150" />
		</colgroup>
		<tr>
			<th>견적명</th>
			<td>
				<INPUT type="text" name="P_QUOT_BID_MASTER_NM" class="input" value="<%=params.get("P_QUOT_BID_MASTER_NM") %>" style="width:90%"> 
			</td>
			<th>마감일자</th>
			<td>
				<%= InputText.get("p_quot_bid_from_dt", params.get("p_quot_bid_from_dt"), 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:dlgCalendar('p_quot_bid_from_dt');">
				~
				<%= InputText.get("p_quot_bid_to_dt", params.get("p_quot_bid_from_dt"), 10, 50, "hangule,center, desc=마감일,ReadOnly") %>
				<!-- <INPUT type="text" name="p_quot_bid_to_dt" id="p_quot_bid_to_dt" class="input" value="" onClick="JavaScript:dlgCalendar('p_quot_bid_to_dt');" style="width:70px;text-align:center" ReadOnly> -->
				<IMG name="start_img" id="calender_to" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('p_quot_bid_to_dt');">
				<IMG name="dataClear1" id="dataClear1" src="/img/buyer/button/bt_eraser1.gif" border="0" align="absmiddle" style="cursor:pointer;">
			</td>
			<td class="button">
				<span class="btnSearch center" id="btnSearch"><a href="javascript:void(0);">검색</a></span>
			</td>
		</tr>
	</table>
	
</TD></TR>
</TABLE>
	<div id="sheet1_div" style=" padding-top:5px; height: auto; min-height: 300px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '300px');</script>
	</div>
</FORM>
