<!--#include virtual="/common/file/inc_head.asp"-->	
<%
v_year = InputValue( request.querystring("p_year") )
v_month = InputValue( request.querystring("p_month") )

If v_year = "" Then v_year = year(now)
If v_month = "" Then v_month = Right( "0" & month(now), 2 )

a_num = "72108979"
tablename = "board_1"

Set ST = New SelectTable


thisYM = v_year & "-" & v_month

where_query = " where (b_sdate like '" & thisYM & "%' or b_edate like '" & thisYM & "%') and b_id = '" & SESSION("ss_m_id") & "' "
orderby_query = " order by b_sdate asc"
sql = "select b_num, b_subject, b_sdate, b_edate, b_temp1 from " & tablename & where_query & orderby_query
rs = ST.selectQueryTable( sql )

%>
<script type="text/javascript">
//<![CDATA[
function alarmOk( obj ){
	var checked = obj.checked;
	var b_num = $(obj).data("b_num");
	var b_temp1 = "N";
	if( checked ){ b_temp1 = "Y"; }
	$.ajax({
		type: "POST"
		,url: "./ajax_alarm_ok.asp"
		,data: "a_num=<%=a_num%>&b_num="+b_num+"&b_temp1="+b_temp1
		,async:false
		,error:function(request, status, error){
			alert("code:"+request.staus+"\nmessage:"+request.responseText);
			//alert("설정실패\n\n잠시후 다시 시도하세요.");
			if(b_temp1 == "Y"){
				$(obj).attr("checked", false);
			}else{
				$(obj).attr("checked", true);
			}
		}
		,success: function(msg){
			//alert(msg);
		}
	});

}
//]]>
</script>
<!-- 타이틀 -->
<div id="cont_head">
	<h2>일정관리</h2>
</div>
<!-- //타이틀 -->
<!-- 내용 -->
<div id="cont_wrap">
	<!-- 일정관리 -->
	<div class="s0301">
		<!--#include file="inc_calendar.asp"-->
		<!-- 일정리스트 -->
		<div class="sche_list">
			<table class="table2">
				<colgroup>
					<col width="30%" />
					<col width="*" />
					<col width="20%" />
				</colgroup>
				<thead>
					<tr>
						<th scope="col">날짜</th>
						<th scope="col">일정내용</th>
						<th scope="col">문자설정</th>
					</tr>
				</thead>
			</table>
			<div class="list_box">
				<table class="table2">
					<colgroup>
						<col width="30%" />
						<col width="*" />
						<col width="20%" />
					</colgroup>
					<tbody>
<%
If isnull(rs) Then
%>
						<tr>
							<td colspan="3">일정이 없습니다.</td>
						</tr>
<%
else
	For i = 0 To ubound( rs )
		ST.arr2Value( rs(i) )
		b_date = b_sdate
		If b_sdate <> b_edate Then
			b_date = b_date & "<br />~ " & b_edate
		End If
		
		href = "02_01.asp?b_num=" & b_num
		href = href & "&prepage=" & server.urlencode(NOWPAGE)
		href = href & "&p_year=" & server.urlencode(v_year)
		href = href & "&p_month=" & server.urlencode(v_month)
%>
						<tr>
							<th scope="row"><%=b_date%></th>
							<td style="text-align:left;padding:0px 10px 0px 10px;"><a href="<%=href%>"><%=b_subject%></a></td>
							<td><input type="checkbox" id="checkbox-11-<%=i%>" <%=chkRadio(b_temp1, "Y")%> onclick="alarmOk(this);" data-b_num="<%=b_num%>" /><label for="checkbox-11-<%=i%>"></label></td>
						</tr>
<%
	next
End if
%>
					</tbody>
				</table>
			</div>
			<div class="btngroup">
				<ul class="btn_nrm column1">
<%
href = "02_01.asp?prepage=" & server.urlencode(NOWPAGE)
href = href & "&p_year=" & server.urlencode(v_year)
href = href & "&p_month=" & server.urlencode(v_month)
%>
					<li><a href="<%=href%>" class="nrm1">일정쓰기</a></li>
				</ul>
			</div>
		</div>
		<!-- //일정리스트 -->
	</div>
	<!-- //일정관리 -->
</div>
<!-- //내용 -->

<!--#include virtual="/common/file/bottom.asp"-->
<%
function todaySchedule( thisdate )
	
	Dim ST
	Dim sql, cnt
	Set ST = New SelectTable

	where_query = " where b_sdate <= '" & thisdate & "' AND b_edate >='" & thisdate & "' and b_id = '" & SESSION("ss_m_id") & "' "
	sql = "select count(*) as cnt from " & tablename & where_query
	cnt = ST.selectQueryColumn( sql )

	todaySchedule = cnt

End function
%>