<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ 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="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<script type="text/javascript">
$(document).ready(function(){
	$(".fileView").children('img').remove();
});

function changeValue(obj){ 
	$('#atFileBasicWrite').val(obj.value);
}

function changeValueWork(obj){ 
	$('#atFileBasicWriteWork').val(obj.value);
}
var doubleSubmitFlag = false; //중복 등록 방지를 위한 변수
function fnInsert(){
	
	
	if($("#atFileBasicWrite").val() == '' && $("#atchFileSttus").val() == 'N' ){
		alert("사업자등록증을 첨부해주세요.")
		return false;
	}
	
	if($("#atFileBasicWriteWork").val() == '' && $("#workAtchFileSttus").val() == 'N' ){
		alert("재직증명서를 첨부해주세요.")
		return false;
	}
	 
	if (confirm("재등록 하시겠습니까?")) {
		
	var form = document.mberManageVO;
	

		 
		var _fileForm2 = new Array();
		var data = new FormData(form);
		
/* 		_fileForm2.forEach(function(obj, idx) {
			alert(obj+"@@@"+idx);
			if (obj) data.append("file"+idx, obj.fileObj);
		});
 */		
		if(doubleSubmitFlag){
			alert("이미 재등록하셨습니다.");
			return false;
		}else{		
			$.ajax({
				cache : false
				,url : "<c:url value='/web/user/login/usrJoinReInsertAjax.do'/>"
				,async:false
				,type : 'POST'
				,data : data
				,dataType:'json'
				,processData: false
				,contentType: false
				,success : function(returnData, status){
					if(returnData.result == "success") {
						alert("기업회원 가입 재등록이 완료되었습니다.");
						doubleSubmitFlag = true;
						 location.href='/web/main/mainPage.do'; //마이페이지로 이동
					} else{ 
						alert(returnData.message);
						return;
					}
				}
				,error : function(request , status, error){
					alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
				}
			});
		}
	}
}

</script>
<style type="text/css">
.skip_menu, .quickMenu, .header, .footer {display:none !important;}
#container {padding-top:50px;}
#container .inner {padding-bottom:50px;}
.mypage_content {padding:0;}
.mypage_content .text_top p {line-height:28px;}
.input_list .list_title span {position:absolute;left:80px;top:0;font-size:16px;font-weight:400;color:#e40000;white-space:nowrap;}
.input_list .input_list_item .input_right strong {font-weight:500;}
.msattach_noti {margin:40px 0 0;font-size:18px;font-weight:300;text-align:center;color:#666;}
.msattach_noti strong {font-weight:500;color:#222;}
.mem_btnWrap3 {margin:50px 0 0;}
</style>
<div class="inner">
	<!-- send top -->
	<div class="send_top">
		<!-- 마이페이지 - 기업회원 전환 -->
		<form id="mberManageVO" name="mberManageVO" action="/web/user/login/usrJoinInsert.do" method="post" enctype="Multipart/form-data">
			<input type="hidden" name="mberId" value="${cmpChangeManageVO.mberId}"/>
			<input type="hidden" name="uniqId" value="${cmpChangeManageVO.uniqId}"/>
			<input type="hidden" name="bizType" value="${cmpChangeManageVO.bizType}"/>
			<input type="hidden" name="mberNm" value="${cmpChangeManageVO.mberNm}"/>
			<input type="hidden" name="ceoNm" value="${cmpChangeManageVO.ceoNm}"/>
			<input type="hidden" name="bizNo" value="${cmpChangeManageVO.bizNo}"/> 
			<input type="hidden" name="managerNm" value="${cmpChangeManageVO.managerNm}"/> <!-- 담당자 명 -->
			<input type="hidden" name="moblphonNo" value="${cmpChangeManageVO.moblphonNo}"/>
			<input type="hidden" name="atchFileSttus" id="atchFileSttus" value="${cmpChangeManageVO.atchFileSttus}"/>
			<input type="hidden" name="workAtchFileSttus" id="workAtchFileSttus" value="${cmpChangeManageVO.workAtchFileSttus}"/>
			<input type="hidden" name="cmpHstId" id="cmpHstId" value="${cmpChangeManageVO.cmpHstId}"/>
			<!-- 재등록 전 기존 첨부파일 ID, atchFIleId를 사용하지 못하는 이유 - 첨부파일 다운로드 공통(selectBBSFileInfs.do)에서 이미 name="atchFileId" 사용 -->
			<input type="hidden" name="beforeAtchFileId" id="beforeAtchFileId" value="${cmpChangeManageVO.atchFileId}"/>
			<input type="hidden" name="beforeWorkAtchFileId" id="beforeWorkAtchFileId" value="${cmpChangeManageVO.workAtchFileId}"/>
			
			<div class="mypage_content current">
				<div class="mem_cont_in">
					<div class="text_top">
						<!-- 심사 반려 상태 -->
						<c:if test="${cmpChangeManageVO.hstSttus eq '03'}">
							<p>고객님은 아래와 같은 사유로 인해 <strong>심사 반려 상태</strong>입니다.<br>필요서류를 재등록해주세요.</p>
							<dl>
								<dt>반려사유</dt>
								<dd><c:out value="${cmpChangeManageVO.returnCn}"/></dd>
							</dl>
						</c:if>
						<!-- 승인 심사중 상태 -->
						<c:if test="${cmpChangeManageVO.hstSttus eq '01'}">
							<p>현재 기업회원 가입 <span>심사중</span>입니다.<br/>기업회원 가입불가 또는 보완사항 발생 시 등록하신<br>대표 휴대폰 번호로 문자 안내해드립니다.</p>
						</c:if>
					</div>
					<!-- 기업정보 심사중 상태-->
					<div class="input_list">
						<p class="list_title">기업정보<span>요청정보는 한달간 유효합니다.</span></p>
						<div class="input_list_item colorW">
							<div class="input_left">아이디</div>
							<div class="input_right">
								<c:out value="${cmpChangeManageVO.mberId}" />
							</div>
						</div>
						<div class="input_list_item colorW">
							<div class="input_left">사업자등록번호</div>
							<div class="input_right">
								<c:out value='${fn:substring(cmpChangeManageVO.bizNo, 0, 3)}'/>-<c:out value='${fn:substring(cmpChangeManageVO.bizNo, 3, 5)}'/>-<c:out value='${fn:substring(cmpChangeManageVO.bizNo, 5, 10)}'/>
							</div>
						</div>
						<div class="input_list_item colorW">
							<div class="input_left">요청일</div>
							<div class="input_right">
						    	<fmt:parseDate value='${cmpChangeManageVO.frstRegistPnttm}' var='frstRegistPnttm' pattern="yyyy-MM-dd HH:mm:ss" />
								<fmt:formatDate value="${frstRegistPnttm}" pattern="yyyy-MM-dd HH:mm"/>
							</div>
						</div>
						<div class="input_list_item colorW">
							<div class="input_left">문서정보</div>
							<div class="input_right">
								<!-- 수신문서 없을 때 노출되는 영역 -->
								<c:if test="${empty cmpChangeManageVO.atchFileId  && empty cmpChangeManageVO.workAtchFileId}">
									<strong>수신문서 없음</strong>
								</c:if>
								<!-- 파일 첨부시 노출 되는 영역 -->
								<c:if test="${not empty cmpChangeManageVO.atchFileId}">
									<c:import url="/cmm/fms/selectBBSFileInfs.do" charEncoding="utf-8">
										<c:param name="param_atchFileId" value="${cmpChangeManageVO.atchFileId}" />
									</c:import>
									&nbsp;
								</c:if>
								<c:if test="${not empty cmpChangeManageVO.workAtchFileId}">
									<c:import url="/cmm/fms/selectBBSFileInfs.do" charEncoding="utf-8">
										<c:param name="param_atchFileId" value="${cmpChangeManageVO.workAtchFileId}" />
									</c:import>	
								</c:if>
							</div>
						</div>
						<!-- 심사 반려 상태 -->
						<c:if test="${cmpChangeManageVO.hstSttus eq '03'}">
							<c:if test="${cmpChangeManageVO.atchFileSttus eq 'N'}">	<!-- 사업자등록증 반려 상태 -->
								<div class="input_list_item">
									<div class="input_left"><span class="essential">*</span>사업자등록증 첨부</div>
									<div class="input_right">
										<label for="atFileBasicWrite" class="label">사업자등록증 첨부</label>
										<input type="text" class="list_inputType1" disabled id="atFileBasicWrite">
										<div class="list_btn_wrap">
											<span>사업자등록증 첨부(5MB 이내)</span>
											<input type="file" name="file" id="file"  style="display: none" onchange="changeValue(this); return false;" />
											<button type="button" onclick="document.all.file.click(); return false;">파일첨부</button>
										</div>
									</div>
								</div>
							</c:if>
							<c:if test="${cmpChangeManageVO.workAtchFileSttus eq 'N'}"> <!-- 재직증명서 반려 상태 -->
								<div class="input_list_item">
									<div class="input_left input_left_poe"><span class="essential">*</span>재직증명서<span class="poe_noti2">(대표자는 생략)</span></div>
									<div class="input_right">
										<label for="atFileBasicWriteWork " class="label">재직증명서 첨부</label>
										<input type="text" class="list_inputType1" disabled id="atFileBasicWriteWork">
										<div class="list_btn_wrap">
											<span>재직증명서 첨부(5MB 이내)</span>
											<input type="file" name="fileWork" id="fileWork" class="input-file" style="display: none" onchange="changeValueWork(this); return false;" />
											<button type="button" onclick="document.all.fileWork.click(); return false;">파일첨부</button>
										</div>
									</div>
								</div>
							</c:if>
						</c:if>
					</div>
					<!--// 기업정보 -->
					<div class="msattach_noti">심사는 평일 업무시간 기준으로 <strong>회원가입 신청 후 2시간정도 소요</strong>됩니다.</div>
					<div class="mem_btnWrap3">
						<!-- 심사 반려 상태 -->
						<c:if test="${cmpChangeManageVO.hstSttus eq '03'}">
							<button type="button" class="mem_btn5" onclick="fnInsert(); return false;">재등록</button>
						</c:if>
						<button type="button" class="btnType2" onclick="location.href='/web/main/mainPage.do'">메인</button>
					</div>
				</div>
			</div>
			<!--// 마이페이지 - 비밀번호 변경 -->
		</form>
	</div>
	<!--// send top --> 
</div>