<%--
  Class Name : MsgHolidayModifyPopup.jsp
  Description : 공휴일 등록 팝업
  Modification Information

      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2024.07.29    우영두          최초 생성

    author   : 우영두
    since    : 2022.07.01

    Copyright (C) 2009 by MOPAS  All right reserved.
--%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="ec" uri="/WEB-INF/tld/ecnet_tld.tld"%>
<% pageContext.setAttribute("newLineChar", "\r\n"); %>
<% pageContext.setAttribute("newLineChar2", "\n"); %>
<%   
	response.setHeader("Cache-Control","no-store");   
	response.setHeader("Pragma","no-cache");   
	response.setDateHeader("Expires",0);   
	if (request.getProtocol().equals("HTTP/1.1")) response.setHeader("Cache-Control", "no-cache"); 
%> 
<!DOCTYPE html>
<html lang="kr">
<head>
<title>공휴일 등록</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="/pb/css/reset.css">
<link rel="stylesheet" href="/pb/css/common.css">
<link rel="stylesheet" href="/pb/css/content.css">
<link rel="stylesheet" href="/pb/css/popup.css">

<style>
.pageCont .tbType1 tbody tr td.sms_detail {overflow:inherit;text-overflow:inherit;position:relative;}
.pageCont .tbType1 tbody tr td.sms_detail p {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.pageCont .tbType1 tbody tr td.sms_detail .sms_detail_hover {overflow:hidden;text-overflow:ellipsis;display:none;word-wrap:break-word;-webkit-line-clamp:20;-webkit-box-orient:vertical;position:absolute;left:-5px;top:45px;width:calc(100% + 150px);padding:15px;line-height:20px;white-space:normal;border:1px solid #e5e5e5;background:#fff;border-radius:5px;box-sizing:border-box;box-shadow:0px 3px 10px 0px rgb(0 0 0 / 0.2);z-index:1;font-size:14px;text-align:left;}
.pageCont .tbType1 tbody tr td.sms_detail .sms_detail_hover:after {content:'';position:absolute;left:0;bottom:0;width:100%;height:10px;background:#fff;border-radius:0 0 5px 5px;}
.pageCont .tbType1 tbody tr td.sms_detail:hover .sms_detail_hover {display:-webkit-box;}
</style>

<script type="text/javascript" src="/pb/js/jquery-3.5.0.js"></script>
<script type="text/javascript" src="/pb/js/common.js"></script>
<script type="text/javascript" src="<c:url value='/js/EgovCalPopup.js'/>"></script>
<script type="text/javaScript" language="javascript">

function fn_search(){
	var searchKeyword = $('input[name=searchKeyword]').val();
	$('input[name=searchKeyword]').val(searchKeyword.replace(/(\s*)/g, ""));
	linkPage(1);
}

function linkPage(pageNo){
	var listForm = document.listForm ;
	listForm.pageIndex.value = pageNo ;
	if( $('#ntceBgndeYYYMMDD').val() != '' && $('#ntceEnddeYYYMMDD').val() != '' ){
		var iChkBeginDe = Number($('#ntceBgndeYYYMMDD').val().replaceAll("-", ""));
		var iChkEndDe =  Number($('#ntceEnddeYYYMMDD').val().replaceAll("-", ""));
		if(iChkBeginDe > iChkEndDe || iChkEndDe < iChkBeginDe ){
			alert("검색시작일자는 종료일자 보다 클수 없습니다.");
			return;
		}
	}
	
	$('#ntceBgnde').val($('#ntceBgndeYYYMMDD').val()) ;
	$('#ntceEndde').val($('#ntceEnddeYYYMMDD').val()) ;
	
	listForm.action = "<c:url value='/uss/umt/user/EgovGnrlselectedUserMsgDataListAjax.do'/>";
	listForm.submit();
}


function fnCheckAll() {
	if( $("#checkAll").is(':checked') ){
	  $("input[name=del]").prop("checked", true);
	}else{
	  $("input[name=del]").prop("checked", false);
	}
}

/* 체크된 메인배너  목록 삭제 */
function fn_delete(){
	if($("input[name=del]:checked").length == 0){
		alert("선택된 항목이 없습니다.");
		return;
	}
		
	if (confirm("해당 문자를 삭제하시겠습니까?")){
		frm = document.listForm;
		frm.action = "<c:url value='/uss/ion/msg/SendMsgDelete.do' />";
	    frm.submit();
	}
}

/* 수정 화면*/
function fn_modify(msgId){
	var frm = document.modiForm ;
	frm.msgId.value = msgId ;
	frm.submit();
}

/* 수정 화면*/
function fn_detail_list(msgGroupId){
	var frm = document.modiForm ;
	frm.msgGroupId.value = msgGroupId ;
	frm.submit();
}

/* 날자 초기화  */
function init_date(){
	$('#ntceBgndeYYYMMDD').val('');
	$('#ntceEnddeYYYMMDD').val('');
	$('#ntceBgnde').val('');
	$('#ntceEndde').val('');
	
	$('#searchKeyword').val('');
	$('#sendKind').val('').prop("selected",true);
	$('#searchCondition').val('').prop("selected",true);
}


//엑셀 다운로드
function sendMsgExcelDownload(){
	var frm = document.listForm;
	$('#ntceBgnde').val($('#ntceBgndeYYYMMDD').val()) ;
	$('#ntceEndde').val($('#ntceEnddeYYYMMDD').val()) ;
	
	var ntceBgnde = $('#ntceBgndeYYYMMDD').val();
	var ntceEndde = $('#ntceEnddeYYYMMDD').val();

	frm.ntceBgnde.value = ntceBgnde;
	frm.ntceEndde.value = ntceEndde;
	
	frm.method = "post"; 
	frm.action = "<c:url value='/uss/ion/msg/selectMberSendMsgExcelDownload.do'/>";
	frm.submit(); 
}
  
function fnHolidayReg(){
	
	var form = document.modiForm;
	
	if(form.holidayNm.value == ""){
		alert("휴일명을 입력해 주세요.");
		return false;
	}
	
	if(form.ntceBgndeYYYMMDD.value == ""){
		
		alert("휴일 일자를 선택해 주세요.");
		return false;
		
	}
	
	if(form.holidayType.value == ""){
		
		alert("휴일 구분을 입력해 주세요.");
		return false;
		
	}
	
	if(confirm("공휴일을 등록하시겠습니까?")){
		
		var holidayDate = form.ntceBgndeYYYMMDD.value;
		
		url = "/let/mjo/holiday/insertHolidayRegistAjax.do";
		var jsonParam = {"holidayNm" : form.holidayNm.value, "holidayDate" : holidayDate, "holidayType" : form.holidayType.value};
			
		$.ajax({
	        type: "POST",
	        url: url,
	        data: JSON.stringify(jsonParam),
	        dataType:'json',
	        contentType: 'application/json',
	        async: true,
	        success: function (data) {
				if(data.status == "OK"){
					
					alert(data.message);
					opener.location.reload();
					window.close();
					
				}else if(data.status == "UNAUTHORIZED"){
					
					alert(data.message);
					window.location.href="/uat/uia/EgovLoginUsr.do";
					
				}else{
					
					alert(data.message);
					return false;
					
				}
				
			},
	        beforeSend: function () {
	        	//로딩창 show
	        	$('.loading_layer').addClass('active');
	        }, 
	        complete: function () {
	        	//로딩창 hide
	        	$('.loading_layer').removeClass('active');
	        },
	        error: function (e) { alert("공휴일 정보 등록에 실패하였습니다."); console.log("ERROR : ", e); }
	    });
		
	}
	
}

function fnHolidayUpdt(){
	
	var form = document.modiForm;
	
	if(form.holidayNm.value == ""){
		alert("휴일명을 입력해 주세요.");
		return false;
	}
	
	if(confirm("공휴일 정보를 수정하시겠습니까?")){
		
		var holidayDate = form.ntceBgndeYYYMMDD.value;
		
		url = "/let/mjo/holiday/updateHolidayDataAjax.do";
		var jsonParam = {"holidayId" : form.holidayId.value,"holidayNm" : form.holidayNm.value, "holidayDate" : holidayDate, "holidayType" : form.holidayType.value};
			
		$.ajax({
	        type: "POST",
	        url: url,
	        data: JSON.stringify(jsonParam),
	        dataType:'json',
	        contentType: 'application/json',
	        async: true,
	        success: function (data) {
				if(data.status == "OK"){
					
					alert(data.message);
					opener.location.reload();
					window.close();
					
				}else if(data.status == "UNAUTHORIZED"){
					
					alert(data.message);
					window.location.href="/uat/uia/EgovLoginUsr.do";
					
				}else{
					
					alert(data.message);
					return false;
					
				}
				
			},
	        beforeSend: function () {
	        	//로딩창 show
	        	$('.loading_layer').addClass('active');
	        }, 
	        complete: function () {
	        	//로딩창 hide
	        	$('.loading_layer').removeClass('active');
	        },
	        error: function (e) { alert("공휴일 정보 변경에 실패하였습니다."); console.log("ERROR : ", e); }
	    });
		
	}
	
}

function fnHolidayDel(){
	
	var form = document.modiForm;
	
	if(confirm("공휴일 정보를 삭제하시겠습니까?")){
		
		url = "/let/mjo/holiday/deleteHolidayDataAjax.do";
		var jsonParam = {"holidayId" : form.holidayId.value};
			
		$.ajax({
	        type: "POST",
	        url: url,
	        data: JSON.stringify(jsonParam),
	        dataType:'json',
	        contentType: 'application/json',
	        async: true,
	        success: function (data) {
				if(data.status == "OK"){
					
					alert(data.message);
					opener.location.reload();
					window.close();
					
				}else if(data.status == "UNAUTHORIZED"){
					
					alert(data.message);
					window.location.href="/uat/uia/EgovLoginUsr.do";
					
				}else{
					
					alert(data.message);
					return false;
					
				}
				
			},
	        beforeSend: function () {
	        	//로딩창 show
	        	$('.loading_layer').addClass('active');
	        }, 
	        complete: function () {
	        	//로딩창 hide
	        	$('.loading_layer').removeClass('active');
	        },
	        error: function (e) { alert("공휴일 삭제에 실패하였습니다."); console.log("ERROR : ", e); }
	    });
		
	}
	
	
}

function fnClose(){
	
	window.close();
	
}

</script>
<style>
.calBtn{
    border: none;
    background-color: transparent !important;
    background-image: url(/pb/img/common/calendarIcon.png);
    background-repeat: no-repeat;
    width: 25px;
    height: 25px !important;
    vertical-align: middle;
    margin-left: -38px !important;
    margin-top: -2px !important;
    cursor: pointer;
}
.pageCont {width:100%;padding:50px 30px;box-sizing:border-box;}
.tableWrapTotal {margin:0 0 20px;}
.tableWrapTotal .tbType1 thead tr:first-child {border-width:1px;}
.tableWrapTotal .tbType1 thead tr th {border-left:1px solid #e6e6e6;}
.tableWrapTotal .tbType1 thead tr th:first-child {border-left:0 none;}
.tableWrapTotal .tbType1 thead tr.content th {font-size:14px;}
.tableWrapTotal .tbType1 tbody tr td {border-left:1px solid #e6e6e6;}
.tableWrapTotal .tbType1 tbody tr td:first-child {border-left:0 none;}
.listSerch .select {height:42px;vertical-align:top;}
.pageCont .tbType1 tbody tr td.msg_detail {overflow:inherit;}
.pageCont .tbType1 tbody tr td.msg_detail a {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;}
/* .layer_msg_wrap {position:relative;} */
.layer_msg_wrap .layer_msg_detail {overflow:hidden;display:none;position:absolute;left:50%;top:600px;width:400px;max-height:600px;background:#eee;transform:translateX(-50%);z-index:1;}
.layer_msg_wrap .layer_msg_detail button {position:absolute;right:0;top:0;width:35px;height:35px;}
.layer_msg_wrap .layer_msg_detail button:before {content:'';position:absolute;left:50%;top:50%;width:1px;height:14px;margin:-7px 0 0;background:#fff;transform:rotate(-45deg);}
.layer_msg_wrap .layer_msg_detail button:after {content:'';position:absolute;left:50%;top:50%;width:1px;height:14px;margin:-7px 0 0;background:#fff;transform:rotate(45deg);}
.layer_msg_wrap .layer_msg_detail .title {height:35px;padding:0 15px;font-size:16px;line-height:35px;text-align:left;color:#fff;background:#456ded;border-radius:5px 5px 0 0;}
.layer_msg_wrap .layer_msg_detail .content {overflow-y:auto;max-height:535px;margin:15px;padding:10px 15px;line-height:20px;white-space:normal;background:#fff;}
.layer_msg_wrap .layer_msg_detail .content .rev_cont {text-align:left;}
@media screen and (max-width:916px){
	.pageCont .tableWrap table thead tr th {padding:15px 0;}
}

</style>
</head>
<body>
<div class="loading_layer">
	<div class="loading_container">
		<div class="bar"></div>
		<div class="text">Loading</div>
	</div>
</div>
<form id="modiForm" name="modiForm" method="post">
	<input type="hidden" id="holidayId" name="holidayId" value="<c:out value='${result.holidayId}'/>"/>
	<input type="hidden" name="ntceBgnde" id="ntceBgnde"  value="">
	<input type="hidden" name="ntceEndde" id="ntceEndde"  value="">
	
	<div class="contWrap" style="position:relative;left:inherit;top:inherit;min-height:auto;padding:40px; width:900px; ">
		<div class="pageTitle">
			<!-- <div class="pageIcon"><img src="/pb/img/pageTitIcon4.png" alt=""></div> -->
			<h2 class="titType1 c_222222 fwBold">공휴일 등록</h2>
			<!-- <p class="tType6 c_999999">문자전송리스트 현황을 파악할 수 있습니다.</p> -->
		</div>
		<div class="pageCont" style="min-height: 300px;">
			<table class="tbType2">
				<colgroup>
					<col style="width: 20%">
					<col style="width: 80%">
				</colgroup>
				<tbody>
					<tr>
						<th><span class="reqArea">휴일명</span></th>
						<td colspan="3">
							<input type="text" id="holidayNm" name="holidayNm"  title="아이디" maxlength="30" value="<c:out value='${result.holidayNm}'/>"/>
						</td>
					</tr>
					<tr>
						<th><span class="reqArea">휴일 일자</span></th>
						<td colspan="3">
							<input type="hidden" name="cal_url" id="cal_url" value="/sym/cmm/EgovNormalCalPopup.do">
							<a href="#" onclick="javascript:fn_egov_NormalCalendar(document.forms.modiForm, document.forms.modiForm.ntceBgndeYYYMMDD);">
								<input style="width:auto;min-width: 83px;" type="text" class="date_format" name="ntceBgndeYYYMMDD" id="ntceBgndeYYYMMDD" size="4" maxlength="4" readonly=""
								value="<c:out value='${result.holidayDate}'/>" >
								<input type="button" class="calBtn">
							</a>
						</td>
					</tr>		
					<tr>
						<th><span class="reqArea">휴일 구분</span></th>
						<td colspan="3">
							<select id="holidayType" name="holidayType" style="min-width: 150px;">
								<option value="1" <c:if test="${result.holidayType eq '1'}">selected</c:if> >법정 공휴일</option>
								<option value="2" <c:if test="${result.holidayType eq '2'}">selected</c:if>>임시 공휴일</option>
								<option value="3" <c:if test="${result.holidayType eq '3'}">selected</c:if>>기타</option>
							</select>
						</td>
					</tr>			
				</tbody>
			</table>
			<div class="btnWrap" style="margin-bottom: 15px;">
				<input type="button" class="btnType1"  onclick="fnClose(); return false;" value="닫기">
				<c:choose>
					<c:when test="${result.holidayId > 0}">
						<input type="button" class="btnType2"  onclick="fnHolidayDel(); return false;" value="삭제">
						<input type="button" class="btnType1"  onclick="fnHolidayUpdt(); return false;" value="수정">
					</c:when>
					<c:otherwise>
						<input type="button" class="btnType1"  onclick="fnHolidayReg(); return false;" value="등록">	
					</c:otherwise>
				</c:choose>
			</div>
		</div>
	</div>
</form>
</body>
</html>
