<%--
  - FileName   : PurPricesysPopup.jsp
  - Author(s)  : TC4035
  - Date       : 2024.10.29
  - 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.*" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ 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();
    
	//공통코드
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();

	initCombo.makeComboData(commCodeManager.getCodeRowSet("PUR_PRICESYS_RS","DETAILCD","Y"), "DETAILNM", "DETAILCD");
	String SYS_REASON_CD = initCombo.getCode();
	String SYS_REASON_NM = initCombo.getCodeName();
	
	
    RowSet PricesysRsComboList = CommCodeManager.getCodeRowsetStatic("PUR_PRICESYS_RS", "SUBSTR(CHG_CODE01,1,1)", "Y");
    
    /*표준 미연동 계약 정보 */
	ValueObject pricesysInfo = storage.getValueObject("pricesysInfo");
     if (pricesysInfo == null) {
        // 초기화할 값을 설정
        pricesysInfo = new ValueObject(); // 예: 새로운 ValueObject 생성
    } 
%>

<SCRIPT language="JavaScript">

	function _onReady(){
		jQuery("#btnSave").click(function() {
			if (confirm("저장하시겠습니까?")) {
				var f = document.form1;
				jQuery("#fevent").val("FORM_SAVE");
				submitXmlRequest("/portal/cont/PurPricesysPopup_form.screen", "FORM_SAVE", f, "SUCCESS");	
			}
		}); 
		
		jQuery("#SYS_REASON").attr("readonly", true);
		jQuery("#SYS_REASON").css({'background-color' : '#dedede'});
	}
	

	function doResult(resultObj) {
		try {
			
			if( resultObj.getRequestEvent() == "FORM_SAVE" ) {
				if( resultObj.getSuccess() ) {				
					alert("저장되었습니다.");		
					
					returnValue = new Array(0,"OK");
					parent.popPricesysClose(returnValue);
					
				}else {
					
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
	        showErrorDlg("doResult()", errorObject);
		}
	}


	function inputDataSet(){
		
		if(jQuery("#SYS_REASON option:selected").val() == "00"){	//직접입력
			jQuery("#REMARK").attr("readonly", false);
			jQuery("#REMARK").css({'background-color' : '#ffffff'});
			jQuery("#REMARK").css({'border' : '1px solid #595a5a'});

		}else if(jQuery("#SYS_REASON option:selected").val() == ""){ //선택
			$("#REMARK").val("");
			document.getElementById("REMARK").style.display	=	"";
			jQuery("#REMARK").attr("readonly", true);
			jQuery("#REMARK").css({'background-color' : '#dedede'});
			
		}else{
			$("#REMARK").val("");
			jQuery("#REMARK").attr("readonly", true);
			jQuery("#REMARK").css({'background-color' : '#dedede'});
		}
	}
	
	
	
	
</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="objectNm" value="<%=pricesysInfo.get("OBJECT_NM")%>">
<INPUT type='hidden' name="itemNm" value="<%=pricesysInfo.get("ITEM_NM")%>">
<INPUT type='hidden' name="sysReason" value="<%=pricesysInfo.get("SYS_REASON")%>">
<INPUT type='hidden' name="priceSysId" value="<%=pricesysInfo.get("PRICE_SYS_ID")%>">
<INPUT type='hidden' name="priceSysYn" value="<%=pricesysInfo.get("PRICE_SYS_YN")%>">
<INPUT type='hidden' name="contModId" value="<%=pricesysInfo.get("CONT_MOD_ID")%>">
<INPUT type='hidden' name="corpRegNo" value="<%=pricesysInfo.get("C_VENDCD")%>">
<INPUT type='hidden' name="corpName" value="<%=pricesysInfo.get("C_MEMBER_NAME")%>">
<INPUT type='hidden' name="contNo" value="<%=pricesysInfo.get("CONT_NO")%>">
<INPUT type='hidden' name="modNo" value="<%=pricesysInfo.get("MOD_NO")%>">
<INPUT type='hidden' name="reamrk" value="<%=pricesysInfo.get("REMARK")%>">


	<!-- 제목 및 버튼 -->
<table  width="100%" border="0" cellspacing="0" cellpadding="0" class="ftit_table">
	<colgroup>
		<col width="200" />
		<col width="*" />
	</colgroup>
	<tr>
	   <td align="right">
			<span class="btnSearch center"  id="btnSave"><a>저장</a></span>
	   </td>
   	</tr>
</table>
   	
<!-- 상세 정보 -->   	
<TABLE class="form-table" style="margin-top:10px;">
	<colgroup>
		<col width="300" />
		<col width="*" />
	</colgroup>
	<TR height="40">
		<TH style="text-align:left;">미연동 대상 목적물등 또는 물품등의 명칭</TH>
		<TD style="text-align:left;">
			<textarea name="OBJECT_NM" style="width:98%; height:40px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget"><%=pricesysInfo.get("OBJECT_NM")%></textarea>
		</TD>
	</TR>
	<TR height="40">
		<TH style="text-align:left;">미연동 대상 주요 원재료 명칭</TH>
		<TD style="text-align:left;">
			<textarea name="ITEM_NM" style="width:98%; height:40px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget"><%=pricesysInfo.get("ITEM_NM")%></textarea>
		<%-- 	
		 --%>
		</TD>
	</TR>
	<TR height="80">
		<TH style="text-align:left;">미연동 사유</TH>
		<TD style="text-align:left;">
		<%= HTMLMaker.getSelectTag(PricesysRsComboList, "DETAILCD", "DETAILNM", "SYS_REASON", "width:99%;height=40px;' onChange='inputDataSet();", "<option value=''>선택</option>", pricesysInfo.get("SYS_REASON")) %>
		<textarea name="REMARK" style="width:98%; height:50px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget" readOnly><%=pricesysInfo.get("REMARK")%></textarea> 
		</TD>
	</TR>
</TABLE>
</FORM>