<%--
  Class Name : EgovMainView.jsp 
  Description : 메인화면
  Modification Information
 
      수정일         수정자                   수정내용
    -------    --------    ---------------------------
     2011.08.31   JJY       경량환경 버전 생성
 
    author   : 실행환경개발팀 JJY
    since    : 2011.08.31 
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ 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>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/post.css?ver=1">
<meta http-equiv="Content-Language" content="ko" >
<title>N-CMS</title>
<script src="<c:url value='/js/jquery.js' />"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
<script>
$( document ).ready(function() {
	lineChart_day();
	lineChart_month();
	lineChart_year();
	$('#lineCanvasMonth')[0].style.marginLeft = "18px"; //화면에 맞게 위치 조정
	$('#lineCanvasMonth')[0].style.marginTop = "18px"; 
	
	$('#lineCanvasYear')[0].style.marginLeft = "12px";  //화면에 맞게 위치 조정
	$('#lineCanvasYear')[0].style.marginTop = "18px"; 
	$("#statCondition").change(function(){
		var statCondition = $("#statCondition option:selected").val();
		if(statCondition == '1') lineChart_day();
		if(statCondition == '2') lineChart_month();
		if(statCondition == '3') lineChart_year();
	});
	barChart();
	
	
});

//var lineChart = "";
function lineChart_day(){
	//if(lineChart!="") lineChart.destroy();
	var data = {
	        labels: ${statsDayList.date},
	        datasets:[
	            {
	                label: "",
	                fillColor: "rgb(233,125,125)",
	                /* strokeColor: "rgba(220,220,220,1)",
	                pointColor: "rgba(220,220,220,1)", */
	                pointStrokeColor: "#fff",
	                pointHighlightFill: "#fff",
	                pointHighlightStroke: "rgba(220,220,220,1)",
	                /* data: [2, 3, 5, 7, 11, 13, 17] */
	                data: ${statsDayList.cnt}
	            }
	        ]
	    };
	    var ctx = document.getElementById("lineCanvasDay").getContext("2d");
	    var options = { };
	    new Chart(ctx).Line(data, options);
}


function lineChart_month(){
	//if(lineChart!="") lineChart.destroy();
	var data = {
	        labels: ${statsMonthList.date},
	        datasets:[
	            {
	                label: "",
	                fillColor: "rgb(65,195,150)",
	                /* strokeColor: "rgba(220,220,220,1)",
	                pointColor: "rgba(220,220,220,1)", */
	                pointStrokeColor: "#fff",
	                pointHighlightFill: "#fff",
	                pointHighlightStroke: "rgba(220,220,220,1)",
	                data: ${statsMonthList.cnt}
	            }
	        ]
	    };
	    var ctx = document.getElementById("lineCanvasMonth").getContext("2d");
	    var options = { };
	    new Chart(ctx).Line(data, options);
}

function lineChart_year(){
	//if(lineChart!="") lineChart.destroy();
	var data = {
	        labels: ${statsYearList.date},
	        datasets:[
	            {
	                label: "",
	                fillColor: "rgb(88,143,246)",
	                /* strokeColor: "rgba(220,220,220,1)",
	                pointColor: "rgba(220,220,220,1)", */
	                pointStrokeColor: "#fff",
	                pointHighlightFill: "#fff",
	                pointHighlightStroke: "rgba(220,220,220,1)",
	                data: ${statsYearList.cnt}
	            }
	        ]
	    };
	    var ctx = document.getElementById("lineCanvasYear").getContext("2d");
	    var options = { };
	    new Chart(ctx).Line(data, options);
}


function barChart(){
	var data = {
	        labels: ${statsPcDayList.date},
	        datasets:[
	            {
	                label: "",
	                fillColor: "rgb(62,195,150)",
	                strokeColor: "rgba(220,220,220,1)",
	                data: ${statsPcDayList.cnt}
	            },
	            {
	                label: "",
	                fillColor: "rgb(93,109,196)",
	                strokeColor: "rgba(220,220,220,1)",
	                data: ${statsMobileDayList.cnt}
	            }
	            
	        ],
	    };
	    var ctx = document.getElementById("barCanvas").getContext("2d");
	    var options = {
	    		animation: false
	    };
	    var myBarChart = new Chart(ctx).Bar(data, options);
}

function goSubsession(conUrl , menuNo){
	var subsessionFrom = document.subsessionFrom ;
	subsessionFrom.conUrl.value = conUrl ;
	subsessionFrom.menuNo.value = menuNo ;
	subsessionFrom.submit();
}
</script>
<body>
<noscript>자바스크립트를 지원하지 않는 브라우저에서는 일부 기능을 사용하실 수 없습니다.</noscript>	
<c:import url="/EgovPageLink.do?link=blank" />
<c:import url="/sym/mms/EgovMainMenuHead.do" />
<div id="wrapper">
	<c:import url="/sym/mms/EgovMainMenuLeft.do" />
	<div class="ad_content2">
			<div class="ad_con_head">
				<div class="ad_head_text">
					<p class="today_txt">오늘 접속현황</p>
					<div class="ad_head_ment">
						<ul class="today_txt_2">
							<li>관리자 : <c:if test="${empty adminViewCnt}">0</c:if><c:if test="${!empty adminViewCnt}">${adminViewCnt}</c:if></li>
							<li>홈페이지 : <c:if test="${empty userViewCnt}">0</c:if><c:if test="${!empty userViewCnt}">${userViewCnt}</c:if></li> 
							<!-- <li>페이지 조회수 : 0</li> -->
						</ul>
					</div>
				</div>
			</div>
			<div class="ad_con_body">
				<div class="bo_box">
					<div class="left_bo">
						<p class="left_bo_head">이용문의</p>
						<div class="left_bo_in">
							<ul>
								<c:forEach var="result" items="${boardListAcc}" varStatus="status">
									<li><c:if test="${result.replyAt == 'N'}"><img src="/img/post/reply_p.png"></c:if>
										<c:if test="${result.replyAt != 'N'}"><img src="/img/post/reply_c.png"></c:if>
										<%-- <a href="/cop/bbs/selectBoardArticle.do?bbsId=${result.bbsId}&nttId=${result.nttId}">${result.nttSj}</a><span class="li_today">${result.frstRegisterPnttm}</span></li> --%>
										<a href="#" onclick="goSubsession('/cop/bbs/selectBoardArticle.do?bbsId=${result.bbsId}&nttId=${result.nttId}' , '2000000'); return false;">
										
											 <c:choose>
									           <c:when test="${fn:length(result.nttSj) > 26}">
									            	<c:out value="${fn:substring(result.nttSj,0,25)}"/>....
									           </c:when>
									           <c:otherwise>
									            <c:out value="${result.nttSj}"/>
									           </c:otherwise> 
									          </c:choose>
										</a><span class="li_today">${result.frstRegisterPnttm}</span></li>
								</c:forEach>
							</ul>
						</div>
					</div>
					<div class="right_bo">
						<p class="right_bo_head">최근 게시물</p>
						<div class="right_bo_in">
							<ul>
								<c:forEach var="result" items="${boardListRecent}" varStatus="status">
									<li><span class="right_bo_li">[${result.bbsNm}]</span>
									<a href="#" onclick="goSubsession('/cop/bbs/selectBoardArticle.do?bbsId=${result.bbsId}&nttId=${result.nttId}' , '2000000'); return false;">
										<c:choose>
									           <c:when test="${fn:length(result.nttSj) > 26}">
									            	<c:out value="${fn:substring(result.nttSj,0,25)}"/>....
									           </c:when>
									           <c:otherwise>
									            <c:out value="${result.nttSj}"/>
									           </c:otherwise> 
									          </c:choose>
									</a><span class="li_today">${result.frstRegisterPnttm}</span></li>
								</c:forEach>
							</ul>
						</div>
					</div>
				</div>
				<div class="middle_box">
					<p class="middle_head">
						<c:if test="${!empty ROLE_ADMIN}">
								<a href="#" onclick="goSubsession('/sts/cst/selectConectStats.do?userAt=A' , '5000000'); return false;">접속통계(관리자)</a>
						</c:if>
						<c:if test="${empty ROLE_ADMIN}">
							접속통계(관리자)
						</c:if>
						<%-- <select name="statCondition" id="statCondition" style="margin-bottom: 4px; margin-left: 26px;">
		                	<option value="1" <c:if test="${statType == '1'}">selected="selected"</c:if> >일별</option>
		                    <option value="2" <c:if test="${statType == '2'}">selected="selected"</c:if> >월별</option>
		                    <option value="3" <c:if test="${statType == '3'}">selected="selected"</c:if> >년도별</option>
						</select> --%>
					</p>
					<ul class="gr_li">
						<li><img src="/img/post/today.jpg"> A : 일별</li>
						<li><img src="/img/post/month.jpg"> B : 월별</li>
						<li><img src="/img/post/year.jpg"> C : 년도별</li>
					</ul>
	
					<!-- 차트 -->	
					<p class="gr_img">
						<canvas id="lineCanvasDay" width="988px" height="150px" ></canvas>
						<canvas id="lineCanvasMonth" width="988px" height="100px"></canvas>
						<canvas id="lineCanvasYear" width="988px" height="100px" margin-left="18px"></canvas>
					</p>
				</div>
				<div class="bottom_box">
					<div class="bottom_left_box">
						<p class="l_bottom_head">
							<c:if test="${!empty ROLE_ADMIN}">
								<a href="#" onclick="goSubsession('/sym/log/clg/SelectLoginLogList.do?userAt=A' , '5000000'); return false;">일일 접속 리스트(관리자)</a>
							</c:if>
							<c:if test="${empty ROLE_ADMIN}">
								일일 접속 리스트(관리자)
							</c:if>
						</p>
						<div class="left_bo_box">
							<table class="left_bo_table">
								<colgroup>
									<col style="width: 50px;" />
									<col style="width: 100px;" />
									<col style="width: 150px;" />
									<col style="width: 140px;" />
								</colgroup>
								<thead>
									<tr>
										<th>번호</th>
										<th>관리자명</th>
										<th>접속시간</th>
										<th>IP</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach var="result" items="${adminLogList}" varStatus="status">
									<tr>
										<td>${paginationInfo.totalRecordCount - ((paginationInfo.currentPageNo-1) * paginationInfo.recordCountPerPage + status.index) }</td>
										<td>${result.loginNm}</td>
										<td>${result.creatDt}</td>
										<td>${result.loginIp}</td>
									</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
					<div class="bottom_right_box">
						<p class="r_bottom_head">
						<c:if test="${!empty ROLE_ADMIN}">
							<a href="#" onclick="goSubsession('/sts/cst/selectConectMenuStats.do?userAt=U' , '5000000'); return false;">PC, 모바일 접속통계(사용자)</a>
						</c:if>	
						<c:if test="${empty ROLE_ADMIN}">
							PC, 모바일 접속통계(사용자)
						</c:if>
						</p>
						<ul class="r_bottom_sub">
							<li><img src="/img/post/b_pc.jpg"> PC</li>
							<li><img src="/img/post/b_mobile.jpg"> 모바일</li>
						</ul>
						<p class="gr_2_img">
							<!-- <img src="/img/post/gr_2.jpg"> -->
							<canvas id="barCanvas" width="485px" height="235px"></canvas>
						</p>
					</div>
				</div>
			</div>
		</div>
	</div>
<form name="subsessionFrom" id="subsessionFrom" method="get" action="/sym/mms/goSubsession.do">
	<input name="conUrl" type="hidden" />
	<input name="menuNo" type="hidden" />
</form>
</body>


</html>

