<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<form:form commandName="searchVO" name="searchForm" method="get">
	<form:hidden path="grpNo" />
	<div id="search">
		<ul>
			<li>
				<label for="place1">소속</label>
				<form:select path="place1" cssClass="use">
					<c:forEach var="result" items="${placeList}" varStatus="status">
						<form:option value="${result.code2}" label="${result.codenm}" />
					</c:forEach>
    			</form:select>
			</li>
			<li>
				<label for="name"><spring:message code="target.corp.name" /></label>
				<form:input path="name" />
			</li>
			<c:choose>
			<c:when test="${searchVO.grpNo eq '03'}">
				<li>
					<label for="jobType"><spring:message code="target.corp.jobtype" /></label>
					<form:select path="orgId" cssClass="use">
						<c:forEach var="result" items="${corpOrgList}" varStatus="status">
							<form:option value="${result.key}" label="${result.value}" />
						</c:forEach>
	    			</form:select>
				</li>
			</c:when>
			<c:otherwise>
				<form:hidden path="orgId" />
			</c:otherwise>
			</c:choose>
			<li>
				<span class="btn_blue_l"> 
					<a href="javascript:fn_selectList();">
						<spring:message code="button.goSearch" />
					</a> 
					<img src="<c:url value='/images/rte/btn_bg_r.gif'/>" style="margin-left: 6px;" alt="<spring:message code="button.goSearch" />" />
				</span>
			</li>
		</ul>
	</div>
</form:form>
<div id="divPrintArea">
	<div id ="divPrintTitle" style="display: none;margin: 10px 0 10px 0;">치안대상</div>
	<form:form name="listForm" method="get">
		<input type="hidden" name="idx" />
		<!-- List -->
		<div id="table">
			검색결과&nbsp;:&nbsp;${corpList.size()}건
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				summary="치안대상 목록을 확인 할 수 있습니다.">
				<caption>치안대상 목록</caption>
				<thead>
					<tr>
						<th align="center">번호</th>
						<th align="center"><c:out value="${fieldNameMap.place1str}" /></th>
						<th align="center"><c:out value="${fieldNameMap.name}" /></th>
						<th align="center"><c:out value="${fieldNameMap.location}" /></th>
						<c:if test="${searchVO.grpNo eq '03'}">
							<th align="center"><c:out value="${fieldNameMap.shipCnt}" /></th>
						</c:if>
						<c:if test="${searchVO.grpNo ne '01'}">
							<th align="center"><c:out value="${fieldNameMap.ceo}" /></th>
						</c:if>
						<c:if test="${searchVO.grpNo eq '04' or searchVO.grpNo eq '05'}">
							<th align="center"><c:out value="${fieldNameMap.jobType}" /></th>
						</c:if>
						<c:if test="${searchVO.grpNo eq '03'}">
							<th align="center"><c:out value="${fieldNameMap.memberCnt}" /></th>
						</c:if>
						<c:if test="${searchVO.grpNo eq '05'}">
							<th align="center"><c:out value="${fieldNameMap.partner}" /></th>
						</c:if>
						<c:if test="${searchVO.grpNo eq '03'}">
							<th align="center"><c:out value="${fieldNameMap.basicYear}" /></th>
							<th align="center"><c:out value="${fieldNameMap.fund}" /></th>
						</c:if>
						<th align="center"><c:out value="${fieldNameMap.tel}" /></th>
						<th align="center"><c:out value="${fieldNameMap.fax}" /></th>
						<th align="center"><c:out value="${fieldNameMap.comments}" /></th>
					</tr>
				</thead>
				<tbody>
				<c:choose>
				<c:when test="${corpList.size() > 0}">
					<c:forEach var="result" items="${corpList}" varStatus="status">
					<tr>
						<td align="center" class="listtd"><c:out value="${status.index+1}" /></td>
						<td align="center" class="listtd"><c:out value="${result.place1str}" /></td>
						<td align="center" class="listtd">
							<a href="<c:url value="/target/corp/view.do">
										<c:param name="place1" value="${result.place1}" />
										<c:param name="orgId" value="${result.orgId}" />
										<c:param name="orgNo" value="${result.orgNo}" />
									 </c:url>">
								<c:out value="${result.name}" />
							</a>
						</td>
						<td align="center" class="listtd"><c:out value="${result.location}" /></td>
						<c:choose>
						<c:when test="${searchVO.grpNo eq '02'}">
							<td align="center" class="listtd"><c:out value="${result.ceo}" /></td>
						</c:when>
						<c:when test="${searchVO.grpNo eq '03'}">
							<td align="center" class="listtd"><c:out value="${result.shipCnt}" /></td>
							<td align="center" class="listtd"><c:out value="${result.ceo}" /></td>
							<td align="center" class="listtd"><c:out value="${result.memberCnt}" /></td>
							<td align="center" class="listtd"><c:out value="${result.basicYear}" /></td>
							<td align="center" class="listtd"><c:out value="${result.fund}" /></td>
						</c:when>
						<c:when test="${searchVO.grpNo eq '04'}">
							<td align="center" class="listtd"><c:out value="${result.ceo}" /></td>
							<td align="center" class="listtd"><c:out value="${result.jobType}" /></td>
						</c:when>
						<c:when test="${searchVO.grpNo eq '05'}">
							<td align="center" class="listtd"><c:out value="${result.ceo}" /></td>
							<td align="center" class="listtd"><c:out value="${result.jobType}" /></td>
							<td align="center" class="listtd"><c:out value="${result.partner}" /></td>
						</c:when>
						</c:choose>
						<td align="center" class="listtd"><c:out value="${result.tel}" /></td>
						<td align="center" class="listtd"><c:out value="${result.fax}" /></td>
						<td align="center" class="listtd"><c:out value="${result.comments}" /></td>
					</tr>
					</c:forEach>
				</c:when>
				<c:otherwise>
					<tr>
						<td class="listtd" align="center" colspan="<c:choose>
																	<c:when test="${searchVO.grpNo eq '01'}">7</c:when>
																	<c:when test="${searchVO.grpNo eq '02'}">8</c:when>
																	<c:when test="${searchVO.grpNo eq '03'}">12</c:when>
																	<c:when test="${searchVO.grpNo eq '04'}">9</c:when>
																	<c:when test="${searchVO.grpNo eq '05'}">10</c:when>
																   </c:choose>">
							<spring:message code="msg.nodata" />
						</td>
					</tr>
				</c:otherwise>
				</c:choose>
				</tbody>
			</table>
		</div>
		<!-- /List -->
	</form:form>
</div>
<!-- /PrintArea -->
<form:form name="menuForm" method="get">
	<div id="sysbtn">
		<ul>
			<li>
        		<span class="btn_blue_l">
              		<a href="<c:url value="/target/corp/stats.do"/>"><spring:message code="button.goList" /></a>
              		<img src="<c:url value='/images/rte/btn_bg_r.gif'/>" style="margin-left:6px;" alt="<spring:message code="button.goList" />"/>
        		</span>
   			</li>
   			<c:if test="${loginUserVO.isAdmin}" >
   			<li>
        		<span class="btn_blue_l">
              		<a href="<c:url value="/target/corp/add.do">
              					<c:param name="orgId" value="${searchVO.orgId}" />
              					<c:param name="grpNo" value="${searchVO.grpNo}" />
              					<c:param name="place1" value="${searchVO.place1}" />
              				 </c:url>"><spring:message code="button.create" /></a>
              		<img src="<c:url value='/images/rte/btn_bg_r.gif'/>" style="margin-left:6px;" alt="<spring:message code="button.create" />"/>
        		</span>
   			</li>
   			</c:if>
			<li>
        		<span class="btn_blue_l">
              		<a href="javascript:fn_print();"><spring:message code="button.print" /></a>
              		<img src="<c:url value='/images/rte/btn_bg_r.gif'/>" style="margin-left:6px;" alt="<spring:message code="button.print" />"/>
        		</span>
   			</li>
   			<li>
        		<span class="btn_blue_l">
              		<a href="<c:url value="/target/corp/listtoexcel.do">
              					<c:param name="orgId" value="${searchVO.orgId}" />
              					<c:param name="name" value="${searchVO.name}" />
              					<c:param name="place1" value="${searchVO.place1}" />
              					<c:param name="grpNo" value="${searchVO.grpNo}" />
              				 </c:url>"><spring:message code="button.excel" /></a>
              		<img src="<c:url value='/images/rte/btn_bg_r.gif'/>" style="margin-left:6px;" alt="<spring:message code="button.excel" />"/>
        		</span>
   			</li>			   			
		</ul>
	</div>
</form:form>

<script type="text/javaScript" defer="defer">
<!--
	/* 목록 화면 function */
	function fn_selectList() {
		document.searchForm.submit();
	}

	/* 글 등록 화면 function */
	function fn_addView() {
		document.menuForm.action = "<c:url value='/target/corp/add.do'/>";
		document.menuForm.submit();
	}
	
	/* 출력 */
	function fn_print(){
		var divPrintTitle = document.getElementById("divPrintTitle");
		divPrintTitle.style.display = "inline";
		printDiv($("#divPrintArea").html());
		divPrintTitle.style.display = "none";
	}
//-->
</script>