<%--
  - Author(s)  : Hoonseok choi
  - Date       : 2023.02.10
  - Description: 견적업체 입찰금액 상세팝업
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="kr.co.hsnc.common.sql.RowSet" %>
<%@ page import="kr.co.hsnc.common.util.ValueObject" %>
<%@ page import="com.udapsoft.waf.system.*" %>
<%@ page import="com.udapsoft.waf.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.udapsoft.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.common.util.Formatter2"%>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<%@ 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 user       = ctx.getUser();
    ValueObject params     = storage.getParams();
    String event           = storage.getEvent();
    ValueObject Order = storage.getValueObject("Order");
    ValueObject attid = storage.getValueObject("ATT_ID");
    
    
	String ROW =   (String) storage.get("ROW");
	String VENDOR_CD =   (String) storage.get("VENDOR_CD");
	String QUOT_ID =   (String) storage.get("QUOT_ID");
	String QUOT_BID_NO =   (String) storage.get("QUOT_BID_NO");
	String QUOT_BID_DEG =   (String) storage.get("QUOT_BID_DEG");
	String pop_win_id =   (String) storage.get("pop_win_id");
	String FILE_GB =   (String) storage.get("FILE_GB");
	String fevent =   (String) storage.get("fevent");
    ValueObject file = storage.getValueObject(storage.get("FILE_GB"));
    String DEMANDED_ID =   (String) storage.get("DEMANDED_ID");
    String SITE_ATTEND_YN =   (String) storage.get("SITE_ATTEND_YN");
    String ON_SUPP_YN =   (String) storage.get("ON_SUPP_YN");
    String IN_OUT_DIV =   (String) storage.get("IN_OUT_DIV");
    String STATUS_CD =   (String) storage.get("STATUS_CD");
    if(Order.get("PointCount").isEmpty()){
    	Order.set("PointCount", storage.get("PointCount"));
    }
    String PointCount =   Order.get("PointCount");
%>

<SCRIPT language="JavaScript">

	 var must_msg = "(은)는 필수 입력 항목입니다.";
	 
     function _onReady(){
		//doSearchSheet();
		
		$("#SITE_ATTEND_YN").val("<%=Order.get("SITE_ATTEND_YN")%>");
		$("#ON_SUPP_YN").val("<%=Order.get("ON_SUPP_YN")%>");
		$("#IN_OUT_DIV").val("<%=Order.get("IN_OUT_DIV")%>");
		
		 $("#SITE_ATTEND_YN").change(function() {
			 if($("#SITE_ATTEND_YN").val() == "N"){
				$("#SITE_ATTEND_N").show();
				$("#SITE_ATTEND_Y").hide();
			 }else{
				$("#SITE_ATTEND_Y").show();
				$("#SITE_ATTEND_N").hide();
			 }
		 });
		 $("#SITE_ATTEND_YN").change();
		 
		 $("#ON_SUPP_YN").change(function() {
			 if(( $("#IN_OUT_DIV").val() == "O" || $("#ON_SUPP_YN").val() == "N" ) && <%=Order.get("STATUS_CD")%>!="10"){
				$("#btn_save").show();
			 }else{
				$("#btn_save").hide();
			 }
		 });
		 $("#ON_SUPP_YN").change();
		
		 $("#btn_save").click(function() {
			if(confirm("저장하시겠습니까?")){
	    		if(save_must_ck()){
	    			jQuery("#fevent").val("UPDATE_QUOT_DETAIL");
	    			var f = document.form1;
					submitXmlRequest("/quot/outside/QuotAmtPop_form.screen", "UPDATE_QUOT_DETAIL", f);
	    		}
	    	}
		});
		 
		$("#btn_close").click(function(){ 
				window.close();
		});
	}

     function save_must_ck(){
    	if(must_ck_val("ESTI_TOT_AMT","견적금액"))return false;
 		
  		return true;
  	}
    
  // value 값 체크 
 	function must_ck_val(obj,desc){
 		if($("#"+obj).val().length == 0){
 			if(desc.length> 0){
 				alert(desc+must_msg);
 			}else{
 				alert($("#"+obj).attr("desc")+must_msg);
 			}
 			$("#"+obj).focus();
 			return true;
 		}
 		return false;
 	}
  
	 function numberFormat(num) {
		 var pattern = /(-?[0-9]+)([0-9]{3})/;
		 while(pattern.test(num)) {
			 num = num.replace(pattern,"$1,$2");
		 }
		 return num;
	 }
	 
	function doResult(resultObj){
		if( resultObj.getRequestEvent() == "UPDATE_QUOT_DETAIL") {
			if( resultObj.getSuccess() ) {
				alert("저장 되었습니다.");
			}
			else {
				dlgErrorMsg(resultObj);
			}
		}
	}

	/**
	 * 첨부파일 예약 함수
	 */
	function fileDown(file_id){
			var url="/common/file/FileDownloadServlet";
	 		url += "?file_id=" + file_id;
	 		
	 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new");
	}
	
	function doAttachFileDiv(obj) {
		var file_div = "quot/outside/"+"<%=QUOT_BID_NO%>"+"/";
		 if(obj==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj != ''){ 
			viewFileListNew('<%=FILE_GB%>', obj.value, document.form1.p_AttachFile, "N", file_div);
		} 
	}
	
	//첨부파일   
	function doAttachFile(obj,No) {
		var file_div = "quot/purchase/"+"<%=Order.get("QUOT_BID_NO")%>"+"/";
		var file_div2 = "quot/purchase/"+"<%=Order.get("QUOT_BID_NO")%>"+"/"+"<%=Order.get("VENDOR_CD")%>"+"/";
		var upLoadFlg = "N";
		if($("#ON_SUPP_YN").val() == "N" && <%=Order.get("STATUS_CD")%>!="10")	upLoadFlg = "Y";	//오프라인 업체이나 견적마감인 경우도 파일첨부 불가
		if(obj != ''){
			var fileName = "첨부자료";
			viewFileListNew("QUOT_SUPP_"+"<%=Order.get("VENDOR_CD")%>"+obj.value, obj.value, document.form1.p_AttachFile2, upLoadFlg, file_div2, null, null, null, null, "N", fileName);
		}
	}
	
    document.onkeydown 		= closePopupWindow;
    //document.body.onload = _onReady;
</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="<%=fevent %>">
<INPUT type="hidden" name="VENDOR_CD" value="<%=VENDOR_CD%>">
<INPUT type="hidden" name="QUOT_BID_NO" value="<%=QUOT_BID_NO%>">
<INPUT type="hidden" name="QUOT_BID_DEG" value="<%=QUOT_BID_DEG%>">
<INPUT type="hidden" name="FILE_GB" value="<%=FILE_GB%>">
<INPUT type="hidden" name="SITE_ATTEND_YN" value="<%=SITE_ATTEND_YN%>">
<INPUT type="hidden" name="ON_SUPP_YN" value="<%=ON_SUPP_YN%>">
<INPUT type="hidden" name="IN_OUT_DIV" value="<%=IN_OUT_DIV%>">
<INPUT type='hidden' name="ATT_ID" value="<%=Order.get("ATT_ID")%>">
<INPUT type="hidden" name="quot_id" value="<%=QUOT_ID %>">
<INPUT type="hidden" name="BID_STATUS_CD" value="10">

<table cellspacing="1" cellpadding="0" width="100%">
<colgroup>
	<col width="350" />
	<col />
</colgroup>
<tr height="100%">
<td valign="top">
	<table class="form-table">
		<colgroup>
			<col width="140" />
			<col />
		</colgroup>
	<tr height="25">
	<th>사업자번호</th>
	<td><%=Order.get("VENDOR_NO")%></td>
	</tr>
	<tr height="25">
	<th>업체명</th>
	<td><%=Order.get("VENDOR_NAME")%></td>
	</tr>
	</table>
	
	<TABLE class="form-table" id=SITE_ATTEND_N>
		<colgroup>
			<col width="140" />
			<col />
		</colgroup>
	<TR height="25"> 
	  <th>불참 사유</th>
	  <TD colspan="2">
		<textarea name="SITE_ATTEND_REASON" id="SITE_ATTEND_REASON" style="width:98%; height:80px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget" onkeyup="textareaResize(this)"><%=Order.get("SITE_ATTEND_REASON")%></textarea> 
	  </TD>
	</tr>
	</TABLE>
	
	<TABLE class="form-table" id=SITE_ATTEND_Y>
		<colgroup>
			<col width="140" />
			<col />
		</colgroup>
	<tr height="25">
	<th>견적금액</th>
	<td>
	<%= InputText.get("ESTI_TOT_AMT", Formatter2.currency(Order.get("ESTI_TOT_AMT"),0), 30, 15, "desc=견적금액,Number,right","Number") %>원	
	</td>
	</tr>
	<tr height="25">
	<th>최종 견적 제출 일시</th>
	<td><%=Order.get("SUBMIT_DT")%></td>
	</tr>
	<tr height="100">
	<th>업체 의견</th>
	<TD colspan="2">
		<textarea name="REMARK" id="REMARK" style="width:98%; height:80px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget" onkeyup="textareaResize(this)"><%=Order.get("REMARK")%></textarea> 
    </TD>
	</tr>
	<tr height="100">
	<th>첨부파일</th>
	<td valign="top">
	   <%-- <div id="attach_file_view" class="attach_file_view" >
	   <%=FileManager.getFileListForDiv(FILE_GB, DEMANDED_ID) %>
	   </div> --%>
	   <TEXTAREA name="p_AttachFile2" id="p_AttachFile2" style="width:85%;height:80px" rows="1" class="input" readOnly><%=attid.get("ATT_ID") %></TEXTAREA>
	                    <IMG id='search_spot_button' onClick="doAttachFile(document.form1.quot_id,2);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'>
	</td>
	
	<%-- <TH class="required">첨부자료</TH>
	<TD>
	<TEXTAREA name="p_AttachFile2" id="p_AttachFile2" style="width:85%;height:80px" rows="1" class="input" readOnly><%=fileout.get("DOC_ETC_OUT") %></TEXTAREA>
	                    <IMG id='search_spot_button' onClick="doAttachFile(document.form1.quot_id,2);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'>
	</TD> --%>
	
	</tr>
	<tr height="25">
	<td colspan="2" style="text-align: center;"> 
		<span class="btnSearch center"><a href="javascript:void(0);" id="btn_save">저장</a></span>
		<span class="btnSearch center"><a href="javascript:void(0);" id="btn_close">닫기</a></span>
    </td>
    </tr>
	</table>
</td>
</tr>
</table>

</form>

