달력, 스케줄
본문 바로가기
IT. 컴퓨터

달력, 스케줄

by 솔기잇 2013. 12. 23.



** jsp


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


<input type="hidden" id="headerTxt" value="<message:message code="calendar.tab.calendar" />" />

<input type="hidden" id="footerShowIdx" value="3" />


<div class="content">

<c:forEach items="${list}" var="list" varStatus="listStatus">

<input type="hidden" id="attendance_day${list.ATTENDANCE_DATE}" value="${list.ATTENDANCE_TYPE}" />

</c:forEach>

<ul class="tab">

<li class="on" style="width:643px;" onclick="goMenuByURL('/calendar/calendarList.do');"><span><message:message code="calendar.tab.calendar" /></span></li>

<li style="width:644px;" onclick="goMenuByURL('/calendar/calendarFood.do');"><span><message:message code="calendar.tab.food" /></span></li>

</ul>

<div class="calendar" id="calendar">

<div id="calendarDiv"></div>

<ul>

<li id="dayDate">

<div id="date_slct"></div>

</li>

<li id="dayContent">

<div id="date_content"></div>

</li>

</ul>

</div>

</div>


<script type="text/javascript">

$(document).ready(function(){

var nowDate = new Date();               //오늘 날짜 객체 선언  

    var nYear = nowDate.getFullYear();      //오늘의 년도  

    var nMonth = nowDate.getMonth() + 1;    //오늘의 월 ※ 0월부터 시작

    var nDate = nowDate.getDate();          //오늘의 날  

    var nNumday = nowDate.getDay();         //오늘의 요일 0=일요일...6=토요일

  

    var thisYear = "${year}";

    var thisMonth = "${month}";

    var thisDate = "N";

    

    if('${isToday}' == 'Y'){

    thisYear = nYear;

    thisMonth = nMonth;

    thisDate = nDate;

    }

    

showCalendar(thisYear, thisMonth , thisDate);

// style 

bodyHeightSet();

});


//<![CDATA[

function showCalendar(y, m, todayDate) {

var year = y;

var month = m;

var profileType = "${profile_type}";

// alert(profileType);

var text = '<table>';

text += '<thead>';

text += '<tr>';  

text += '<th><button type="button" class="btn_prev" onclick="preYear('+y+','+m+')"></button></th>';

text += '<th colspan="5">';

    text += y + '<message:message code="calendar.txt.calendar.year" />' + ((m < 10) ? ('0' + m) : m) + '<message:message code="calendar.txt.calendar.month" />'; 

    text += '</th>';

    text += '<th><button type="button" class="btn_next" onclick="nextYear('+y+','+m+')"></button></th>';

text += '</tr>';

text += '<tr>';

text += '<th style="font-size:15px"><message:message code="calendar.txt.calendar.sunday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.monday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.tuesday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.wednesday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.thursday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.friday" /></th>';

text += '<th><message:message code="calendar.txt.calendar.saturday" /></th>';

text += '</tr>';

text += '</thead>';

text += '<tbody>';

text += '<tr>';

var d1 = (y+(y-y%4)/4 - (y-y%100)/100 + (y-y%400)/400 + m*2 + (m*5-m*5%9)/9 - (m<3?y%4||y%100==0&&y%400?2:3:4))%7; 

   for (var i=0; i<42; i++) { 

   

       if (i%7 == 0) text += '</tr>\n<tr>'; //한주

       if (i < d1 || i >= d1+(m*9-m*9%8)/8%2+(m==2?y%4||y%100==0&&y%400?28:29:30)) 

           text += '<td> </td>'; 

       else

           text += '<td' + (i%7 ? '' : ' style="color:red;"') + ' class="mealUseClass" id="calendarDate_'+(i+1-d1)+'"><span>' + (i+1-d1) + '</span></td>';

   } 

    document.getElementById('calendarDiv').innerHTML = text + '</tr>\n</tbody>\n</table>';

    

    //학부모에게만

    if(profileType == "T001") {

    //alert("학부모");

    calendarSmileHandle(); // 출석여부(아이콘)

    mealInputHandle(y,m);  // 일정여부

    }else {

    //alert("원장, 선생");

    $("#dayDate").hide();

    $("#dayContent").hide();

    }

    

    // 오늘날자 박아넣기 

    if(todayDate != "N"){

    $(".mealUseClass").removeClass("today");

$("#calendarDate_" + todayDate).addClass("today");

    }

    // 오늘 날짜 클릭해주기 

    $('#calendarDate_'+todayDate).click();

}


//출석된 날짜 아이콘표시(학부모에게만)

function calendarSmileHandle() {

var tdObj = $(".mealUseClass");

for ( var i = 0; i < tdObj.length; i++) {//날짜

var dayTxt = $(".mealUseClass:eq(" + i + ")").text(); // 날짜를 선택

if(dayTxt < 10) {

dayTxt = '0'+ dayTxt; 

}

var isSmileYn = $("#attendance_day" + dayTxt).val(); // 날짜의 값

// alert(dayTxt + ":::" + isSmileYn);

if(isSmileYn == "Y") {  // 날짜값이 있으면

$(".mealUseClass:eq(" + i + ")").append('<em class="smile"></em>'); // 출석 뽑아서 아이콘 표시

}

}

}


//전달 보기

function preYear(y,m) {

var nowDate = new Date();  

    var nYear = nowDate.getFullYear();  

    var nMonth = nowDate.getMonth() + 1;

    

var preYear = y;

var preMonth = m-1;

if(preMonth < 1){

preYear = y-1;

preMonth = 12;

}

if(preYear +''+ preMonth == nYear + '' + nMonth){

location.href="/calendar/calendarList.do";

}else {

location.href="/calendar/calendarList.do?year=" + preYear + "&month=" + preMonth;

}

}


//다음달 보기

function nextYear(y,m) {

var nowDate = new Date();  

    var nYear = nowDate.getFullYear();  

    var nMonth = nowDate.getMonth() + 1;


    var nextYear = y;

var nextMonth = m+1;

if(nextMonth > 12) {

nextYear = y+1;

nextMonth = 1;

}

if(nextYear +''+ nextMonth == nYear + '' + nMonth){

location.href="/calendar/calendarList.do";

}else {

location.href="/calendar/calendarList.do?year=" + nextYear + "&month=" + nextMonth;

}

}


// 클릭 여부 (일정보기)

var mealInputClick = true;

function mealInputHandle(y,m){

$(".mealUseClass").click(function(){

if(!mealInputClick) return false;

$("#date_slct").html('<img src="/statics/img/loading.gif" alt="로딩중입니다." width="40" height="40" />');

$("#date_content").html('<img src="/statics/img/loading.gif" alt="로딩중입니다." width="40" height="40" />');

var day = $(this).text();

if(day < 10) {

day = "0"+ day;

}

$(".mealUseClass").removeClass("select");

$(this).addClass("select");

var postData = { "schedule_date" : (y+''+m+day) };

$.ajax({

url : "/calendar/ajax/calendarJson.do"

 , type : "POST"

 , data : postData 

 , dataType : "json"

 , error : function (e){ mealInputClick = true; } 

 , success : function(json){

 setTimeout(function(){ getMealContent(json); },1000)

 , setTimeout(function(){ getMealDate(json); },1000)

  }

});

window.scrollTo(0,100);

});

}

function getMealDate(json){

var jsonObj = json.calendarMap;

if (jsonObj == undefined ) {

$("#dayDate").hide();

}else if(jsonObj !== ""){

$("#dayDate").show();

  $("#date_slct").html("<message:message code="calendar.txt.calendar.date" />  :   " + jsonObj.SCHEDULE_DATE);

  }

mealInputClick = true;

}

function getMealContent(json){

var jsonObj = json.calendarMap;

if (jsonObj == undefined ) {

$("#dayContent").hide();

}else if(jsonObj !== ""){

$("#dayContent").show();

  $("#date_content").html("<message:message code="calendar.txt.calendar.content" />  :   " + jsonObj.CONTENT);

  }

mealInputClick = true;

}


// style 

function bodyHeightSet() {

var pageHeight = window.innerHeight; // 실제 화면 높이

var scrollObj = document.getElementById("calendar");

scrollObj.style.height = pageHeight + "px";

}

// ]]>

</script>



** controller


@Controller

@RequestMapping(value="/calendar")

public class CalendarController extends BaseController{

/** **/

private static final long serialVersionUID = 1L;

private static final String AJAX_URL = "/ajax";

// List Data Type

/** 페이지 권한 : 원장 **/

public static final String TYPE_DIRECTOR = "" + 0x12345;

/** 페이지 권한 : 학부모 **/

public static final String TYPE_PARENTS  = "" + 0x12343;

/** 페이지 권한 : 선생 **/

public static final String TYPE_TEACHER  = "" + 0x12344;

@Autowired

private CalendarService calendarService;

@RequestMapping(value="/calendarList", method=RequestMethod.GET)

public ModelAndView calendarList(HttpServletRequest request, HttpServletResponse response) throws Exception 

{

String year  = request.getParameter("year");

String month = request.getParameter("month");

LoginVO loginVo = SessionUtil.getLoginSession(request);


String profileType = loginVo.getType();

String profileId   = loginVo.getProfile_id();

String preschoolId = loginVo.getPreschool_id();

ModelAndView mav = new ModelAndView();

HashMap<String, Object> hMap = new HashMap<String, Object>();

hMap.put("profile_id"  , profileId);

hMap.put("preschool_id", preschoolId);

if((year != null && !"".equals(year)) && (month != null && !"".equals(month))){

mav.addObject("year"   , year);

mav.addObject("month"  , month);

mav.addObject("isToday", "N");

hMap.put("where_date"  , year + month);

} else {

mav.addObject("isToday", "Y");

hMap.put("where_date"  , "INIT");

}

List<HashMap<String, Object>> list = calendarService.selectCalendarList(hMap);

if(profileType.equals("T001")){

// 학부모

hMap.put("listType", TYPE_DIRECTOR);

}else if(profileType.equals("T002")) {

// 원장

hMap.put("listType", TYPE_PARENTS);

}else if(profileType.equals("T003")) {

// 선생님

hMap.put("listType", TYPE_TEACHER);

}

mav.addObject("list", list);

mav.addObject("profile_type", profileType);

mav.setViewName(VIEW_TYPE_FRONT + "/calendar/calendarList");

return mav;

}



@RequestMapping(value= AJAX_URL + "/calendarJson", method=RequestMethod.POST)

public @ResponseBody JSONObject calendarJson(HttpServletRequest request, HttpServletResponse response) throws Exception 

{

JSONObject json = new JSONObject();

String scheduleDate = request.getParameter("schedule_date");


HashMap<String, Object> hMap = new HashMap<String, Object>();

hMap.put("schedule_date", scheduleDate);

HashMap<String, Object> calendarMap = calendarService.selectCalendarDetail(hMap);

json.put("calendarMap", calendarMap);

return json;

}



'IT. 컴퓨터' 카테고리의 다른 글

text 박스에 값 넣기  (0) 2014.01.14
엑셀 다운로드  (0) 2014.01.14
Can I borrow uour flip-flops?  (0) 2013.12.23
그건 단지 제안일 뿐이에요...  (0) 2013.12.22
식단 만들기  (0) 2013.12.20

close