<%--
  - FileName   : ItemAddPopup.jsp
  - Author(s)  : chs
  - Date       : 2022.08.03
  - 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.udapsoft.common.code.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>

<%@ 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();
		
	RowSet itemList = storage.getRowSet("itemList");
    
%>
<SCRIPT language="JavaScript">
	
	function _onReady(){
		jQuery("#btnSave").click(function(){
			if($("#MATERIAL_CD").val() == ""){
				alert("추가품목을 선택하십시오.");
				return;
			}
			
			if (confirm("품목을 추가하시겠습니까?")){
				submitXmlRequest("/cont/purchase/ItemAddPopup_form.screen", "ITEM_ADD_SAVE", document.form1);
			}
		});	
		
		jQuery("#btnDel").click(function(){
			if (confirm("등록된 추가품목을 삭제하시겠습니까?")){
				submitXmlRequest("/cont/purchase/ItemAddPopup_form.screen", "ITEM_ADD_DEL", document.form1);
			}
		});
	
		jQuery("#btnClose").click(function(){
		    parent.ItemAddClose();
		});				
	}
	
	function pageinit(){
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "ITEM_ADD_SAVE") {
				if( resultObj.getSuccess() ) {
				    alert("추가되었습니다.");
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}else if( resultObj.getRequestEvent() == "ITEM_ADD_DEL") {
				if( resultObj.getSuccess() ) {
				    alert("삭제되었습니다.");
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		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="PUR_CONT_MOD_ID" value="<%=params.get("PUR_CONT_MOD_ID")%>">
	<INPUT type="hidden" name="PUR_CONT_ID" 	value="<%=params.get("PUR_CONT_ID")%>">
	<INPUT type="hidden" name="DEMANDED_ID" "	value="<%=params.get("pDemID")%>">
	
	<!-- 검색조건 영역 : 시작 -->
	<table class="search-form-table" style="width: 100%">
	    <col width="15%">
		<col width="30%">
		<col width="*">
		<TR height="25"> 
		    <th>추가품목</th>
			<TD colspan="2"> 
				<%=CommCodeManager.getSelectCodeList("ADD_ITEM_CD","MATERIAL_CD","height=18;","<option value=''>--선택--</option>","") %>
			</TD>
			<TD class="button" style="text-align: right;">      
				<!-- 검색버튼 영역 : 시작 -->
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">추가</a></span>
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnDel">삭제</a></span>
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnClose">닫기</a></span>
    			&nbsp;&nbsp;&nbsp;
   			</TD>
  		</TR>
	</TABLE>
</FORM>
