<?
include_once("./_common.php");
?>
<style>
.day_month { text-align:center; font:bold 11px dotum;color:#000 }
.day_week1 { text-align:center; font:normal 11px dotum; color:#d30300; border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; height:25px; }
.day_week2 { text-align:center; font:normal 11px dotum; border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; height:25px; }
.day_day1 { text-align:center; font:normal 11px dotum; color:#d30300; height:20px; }
.day_day2 { text-align:center; font:normal 11px dotum; height:20px; }
</style>
<?
if(!$year){
$year = date("Y");
}
if(!$month){
$month = date("m");
}
if(!$day){
$day = date("j");
}
$next_year = date("Y",strtotime($year."-".$month."-".$day."+1 year"));
$prev_year = date("Y",strtotime($year."-".$month."-".$day."-1 year"));
$prev_year2 = date("Y", mktime (0,0,0,$month-1, $day, $year));
$prev_mon2 = date("n", mktime (0,0,0,$month-1, $day, $year));
$next_year2 = date("Y", mktime (0,0,0,$month+1, $day, $year));
$next_mon2 = date("n", mktime (0,0,0,$month+1, $day, $year));
$time = strtotime($year.'-'.$month.'-01');
list($tday, $sweek) = explode('-', date('t-w', $time)); // 총 일수, 시작요일
$tweek = ceil(($tday + $sweek) / 7); // 총 주차
$lweek = date('w', strtotime($year.'-'.$month.'-'.$tday)); // 마지막요일
?>
<table width="140" height="30" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center"><a href="javascript:chg_calendar('<?=$prev_year2?>','<?=$prev_mon2?>')"><img src="../images/day_prev.gif"></a></td>
<td align="center" class="day_month"><?=$year?>년 <?=$month?>월</td>
<td align="center">
<a href="javascript:chg_calendar('<?=$next_year2?>','<?=$next_mon2?>')"><img src="../images/day_next.gif"></a>
</td>
</tr>
</table>
<table width="205" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="day_week1">일</td>
<td class="day_week2">월</td>
<td class="day_week2">화</td>
<td class="day_week2">수</td>
<td class="day_week2">목</td>
<td class="day_week2">금</td>
<td class="day_week2">토</td>
</tr>
<? for ($n=1,$i=0; $i<$tweek; $i++) { ?>
<tr>
<? for ($k=0; $k<7; $k++) { ?>
<?
if ($n==date("d") && $month == date("m") && $year == date("Y") ) //오늘
{
$t_st = ";background:#ca9569;color:#fff";
} else {
$t_st = "";
}
$sd = mktime("00","00","00",$month,$n,$year);
$s_st = "";
$onc = "";
if($its[sDate] <= $sd && $its[eDate] >= $sd ) {
$td = mktime("00","00","00",date("m"),date("d"),date("Y"));
}
?>
<td align='center' id="<?=$sd?>"<?=$k == 0 ? "class='dd day_day1'" : "class='dd day_day2'" ?> style='<?=$t_st?><?=$s_st?>' <?=$onc?> >
<? if (!(($i == 0 && $k < $sweek) || ($i == $tweek-1 && $k > $lweek))) { ?>
<?=$n?>
<?
$n++
?>
<? } //if?>
<br><!--td채우기-->
</td>
<? } //for?>
</tr>
<? } //for?>
</table>
<script>
function chg_calendar(y,m) {
$.ajax({
type:"post",
url:"calendar.php",
data:"year="+y+"&month="+m,
success:function(dt) {
$("#calgooksu").html(dt);
}
});
}
</script>