<%--
  Class Name : ComPopup.jsp
  Description : 업체선택 팝업  화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2018.06.11   ITN              최초 생성
 
    author   : ITN
    since    : 2018.06.11
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="egovframework.com.cmm.service.EgovProperties"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko">
<title>자산관리</title>
<link rel="stylesheet" href="/direct/css/font.css">
<link rel="stylesheet" href="/direct/css/reset.css">
<link rel="stylesheet" href="/direct/css/enroll_popup.css">
<link rel="stylesheet" href="/direct/css/index.css">
<link rel="stylesheet" href="/direct/css/nice-select.css">
<script src="<c:url value='/js/jquery-1.12.4.min.js' />"></script>
<script src="<c:url value='/js/jstree.min.js' />"></script>
<script src="<c:url value='/js/EgovCalPopup.js' />"></script> 
<script type="text/javaScript" language="javascript">
$( document ).ready(function(){
	setNumberOnly(); //숫자만 입력
	{
	    var w = $('.enroll_popup').width();
	    var h = $('.enroll_popup').height();
	    window.resizeTo(w+25, h+50);
	}
	
	/* 수리내역 등록 */
	$(".save_btn").click(function (event){
		if(!confirm("수리내역을 등록하시겠습니까?")) return; 
		validate_repair();//날짜 세팅
		var frm = document.repairForm;
	   	var data = new FormData(frm);
	   	$.ajax({
	       type: "POST",
	       url: "/uss/itsm/asset/AssetRepairInsertAjax.do",
	       data: data,
	       dataType:'jsonp',
	       processData: false,
	       contentType: false,
	       cache: false,
	       timeout: 600000,
	       success: function (returnData, status) {
	           if(status == 'success'){
		           	if(returnData.result == 'fail'){
		           		alert("등록에 실패하였습니다.");
		           	}else if(returnData.result == 'auth_fail'){
		           		alert("세션이 종료되었습니다.");
		           	}else if(returnData.result =='success'){
						alert("등록되었습니다.");
						if(opener != null){
							opener.getReList('1') ; //수리내역 리로드	
						}
						window.self.close() ;
		           	}
	           }else{
	           	alert("등록에 실패하였습니다.");
	           }
	       },
	       error: function (e) {
	           console.log("ERROR : ", e);
	           alert("등록에 실패하였습니다.");
	       }
	   });
	});
	
	
});

function setNumberOnly(){ //숫자만 입력
	$("input:text[numberOnly]").on("keyup", function(){
	    $(this).val($(this).val().replace(/[^0-9]/g,""));
	});
}

/* validate */
function validate_repair(){
	var astReqPnttmYYYMMDD = document.getElementById('astReqPnttmYYYMMDD').value; //요청일자
	var astRepPnttmYYYMMDD = document.getElementById('astRepPnttmYYYMMDD').value; //수리일자
	var frm = document.repairForm;
	if( astReqPnttmYYYMMDD!=""){
		frm.astReqPnttm.value  = Number(astReqPnttmYYYMMDD.replaceAll("-","") +"000000" );
	}

	if( astRepPnttmYYYMMDD!=""){
		frm.astRepPnttm.value  = Number(astRepPnttmYYYMMDD.replaceAll("-","") +"000000" );
	}
	return true;
}

/* ********************************************************
* PROTOTYPE JS FUNCTION
******************************************************** */
String.prototype.trim = function(){
	return this.replace(/^\s+|\s+$/g, "");
}

String.prototype.replaceAll = function(src, repl){
	 var str = this;
	 if(src == repl){return str;}
	 while(str.indexOf(src) != -1) {
	 	str = str.replace(src, repl);
	 }
	 return str;
}


/* 업체 팝업 클릭시 */
function comPopup() { 
	fileupladOpener = window.open('', 'comOpener', "width=185, height=195, left=30, top=130","location = no","status= no","toolbars= no");
	document.writeForm.method = "post";
	document.writeForm.action = "/uss/itsm/asset/ComPopup.do";
	document.writeForm.target = "ComPopup" ;
	document.writeForm.submit();
}

function fn_search(){
	linkPage(1);
}

function linkPage(pageNo){
	var searchForm = document.searchForm ;
	searchForm.pageIndex.value = pageNo ;
	searchForm.sortOrder.value =  $('#sortOrder').val() ;
	searchForm.pageUnit.value = $('#pageUnit').val();
	searchForm.searchKeyword.value = $('#searchKeyword').val();
	searchForm.searchCondition.value = $('#searchCondition').val();
	searchForm.submit();
}

</script>
</head>
<body>
<form name="repairForm" id="repairForm"  method="post" action="/uss/itsm/asset/AstRepairPopup.do" target="assetOpener">
<input type="hidden" name="astId" id="astId" value="${assetReVO.astId}"/>
<input type="hidden" name="pageType" id="pageType" value="${assetReVO.pageType}"/>
<input type="hidden" name="astReId" id="astReId" value="${assetReVO.astReId}"/>
	<div class="enroll_popup enterprise_call_popup">
		<div class="enroll_popup_title asset_popup_title">
			<img src="/direct/img/enroll_popup_title_bg.png" alt=""> 
			<c:if test="${locVO.deptFlag eq 'repair'}">
				수리업체 불러오기
			</c:if>
			<div class="enroll_popup_title_btns">
				<ul>
					<li><img src="/direct/img/popup_little_icon.png" alt=""></li>
					<li><img src="/direct/img/popup_full_icon.png" alt=""></li>
					<li><img src="/direct/img/popup_close_icon.png" alt=""></li>
				</ul>
			</div>
		</div>
		<div class="enroll_input_left asset_exposure_list">
			<ul>
				<li>
					검&emsp;&emsp;색 <input type="text" class="business_call_serch"><input type="button" value="검색" class="serch_btn">
				</li>
				<li>
					<div class="enterprise_right_table">
						<table>
							<thead>
								<tr>
									<th>
										<input type="checkbox"><label for=""></label>
									</th>
									<th>번호
			                            <div class="sort">
			                                <div class="sort_btn"><img src="/direct/img/sort_up_img.png" alt=""></div>
			                            </div>
			                        </th>
									<!-- <th>대분류</th>
			                        <th>중분류</th> -->
			                        <th>업체명</th>
			                        <th>담당자</th>
			                        <!-- <th>직위</th>
			                        <th>연락처</th>
			                        <th>이메일</th> -->
			                        <th style="width: 300px;">사업자등록번호</th>
									<!-- <th>구분</th>
									<th>사업명</th>
									<th>사업기간</th>
									<th>계약업체</th> -->
								</tr>
							</thead>
							<tbody>
								<c:forEach var="result" items="${companyMngList}" varStatus="status">
								<tr>
			                        <td>
			                        	<input name="del" id="check${status.index}" type="checkbox" value="${result.companyId}" />
			                        	<label for="check${status.index}"></label>
			                        </td>
			                        <td>6</td>
			                        <td>업체명</td>
			                        <td>담당자</td>
			                        <td>사업자 등록번호</td>
			                    </tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</li>
			</ul>
		</div>

		<div class="main1_btn_div">
			<input type="button" class="save_btn" value="저장">
			<input type="button" class="close_btn" value="닫기">
		</div>
	</div>
</form>	
</body>
</html>