mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
직접 달력 계산, 스타일 변경, 요일명 추가, SELECT폼으로 대체
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2599 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9468b6e5e1
commit
7f90125627
2 changed files with 143 additions and 58 deletions
|
|
@ -1,23 +1,31 @@
|
|||
<?php
|
||||
$year = sprintf("%04d",$_REQUEST['year']);
|
||||
$month = sprintf("%02d",$_REQUEST['month']);
|
||||
####################
|
||||
## 연도 범위 설정 ##
|
||||
// 최대
|
||||
$max_year = 2900;//년 (우주가 사라지는 날 까지)
|
||||
// 최소
|
||||
$min_year = 1900;//년 (0년 부터)
|
||||
####################
|
||||
|
||||
$year = $_REQUEST['year'];
|
||||
$month = $_REQUEST['month'];
|
||||
|
||||
$method = $_REQUEST['method'];
|
||||
$fo_id = $_REQUEST['fo_id'];
|
||||
$callback_func = $_REQUEST['callback_func'];
|
||||
|
||||
$day_str = $_REQUEST['day_str'];
|
||||
$day_str = $_REQUEST['day_str']; // 날짜 (ex. 20080101)
|
||||
if($day_str && strlen($day_str)) {
|
||||
$year = substr($day_str,0,4);
|
||||
$month = substr($day_str,4,2);
|
||||
$year = substr($day_str, 0, 4);
|
||||
$month = substr($day_str, 4, 2);
|
||||
}
|
||||
|
||||
if(!(int)$year) $year = date("Y");
|
||||
if(!(int)$month) $month = date("m");
|
||||
if($year < $min_year || $year > $max_year) $year = date("Y");
|
||||
if(!(int)$month || $month < 1 || $month > 12) $month = date("n");
|
||||
|
||||
switch($method) {
|
||||
case 'prev_year' :
|
||||
$year = date("Y", mktime(0,0,0,1,1,$year)-60*60*24);
|
||||
$year --;
|
||||
break;
|
||||
case 'prev_month' :
|
||||
$month --;
|
||||
|
|
@ -34,16 +42,75 @@
|
|||
}
|
||||
break;
|
||||
case 'next_year' :
|
||||
$year = date("Y", mktime(0,0,0,12,31,$year)+60*60*24);
|
||||
$year ++;
|
||||
break;
|
||||
}
|
||||
|
||||
$start_week = date("w", mktime(0,0,0,$month,1,$year));
|
||||
$month_day = date("t", mktime(0,0,0,$month,1,$year));
|
||||
$before_month_month_day = date("t", mktime(0,0,0,$month,1,$year)-60*60*24);
|
||||
// 긴 이름
|
||||
$monthLongName = array(1 => "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
|
||||
|
||||
// 짧은 이름
|
||||
$monthShortName = array(1 => "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
|
||||
|
||||
// 요일 이름
|
||||
$dayName = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
|
||||
|
||||
/*
|
||||
* @brief 윤년 검사
|
||||
*/
|
||||
function isLeapYear($year) {
|
||||
if ($year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief 날짜 수 계산
|
||||
*/
|
||||
function convertDatetoDay($year, $month, $day = 0) {
|
||||
$numOfLeapYear = 0; // 윤년의 수
|
||||
|
||||
// 전년도까지의 윤년의 수를 구한다.
|
||||
for($i = 0; $i < $year; $i++) {
|
||||
if(isLeapYear($i)) $numOfLeapYear++;
|
||||
}
|
||||
|
||||
// 전년도까지의 일 수를 구한다.
|
||||
$toLastYearDaySum = ($year-1) * 365 + $numOfLeapYear;
|
||||
|
||||
// 올해의 현재 월까지의 일수 계산
|
||||
$thisYearDaySum = 0;
|
||||
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
|
||||
$endOfMonth = array(1 => 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
||||
|
||||
for($i = 1; $i < $month; $i++) {
|
||||
$thisYearDaySum += $endOfMonth[$i];
|
||||
}
|
||||
|
||||
// 윤년이고, 2월이 포함되어 있으면 1일을 증가시킨다.
|
||||
if ($month > 2 && isLeapYear($year)) $thisYearDaySum++;
|
||||
|
||||
if(isLeapYear($year)) $endOfMonth[2] = 29;
|
||||
|
||||
if($day) {
|
||||
$thisYearDaySum += $day;
|
||||
return $toLastYearDaySum + $thisYearDaySum - 1;
|
||||
} else {
|
||||
return $endOfMonth[$month];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief 요일 구하기
|
||||
*/
|
||||
function getDayOfWeek($year, $month, $day) {
|
||||
// 0~6의 값을 반환한다. 결과가 0이면 일요일이다.
|
||||
return convertDatetoDay($year, $month, $day) % 7;
|
||||
}
|
||||
|
||||
$start_week = getDayOfWeek($year, $month, 1);
|
||||
$month_day = convertDatetoDay($year, $month);
|
||||
$before_month_month_day = convertDatetoDay( $month == 1 ? $year - 1 : $year, $month == 1 ? 12 : $month - 1);
|
||||
|
||||
$next_year = date("m", mktime(0,0,0,12,31, $year)+60*60*24);
|
||||
$next_month = date("m", mktime(0,0,0,$month,$month_day, $year)+60*60*24);
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html lang="ko" xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
|
@ -67,8 +134,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var date_obj = opener.xGetElementById("date_<?=$fo_id?>");
|
||||
var str_obj = opener.xGetElementById("str_<?=$fo_id?>");
|
||||
var date_obj = opener.xGetElementById("date_<?php echo $fo_id?>");
|
||||
var str_obj = opener.xGetElementById("str_<?php echo $fo_id?>");
|
||||
|
||||
if(date_obj) date_obj.value = date_val;
|
||||
|
||||
|
|
@ -82,99 +149,112 @@
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="popup_content" >
|
||||
<div id="popHeadder">
|
||||
<h1>Calendar</h1>
|
||||
</div>
|
||||
|
||||
<form action="./calendar.php" method="get">
|
||||
<input type="hidden" name="fo_id" value="<?=$fo_id?>"/>
|
||||
<input type="hidden" name="callback_func" value="<?=$callback_func?>"/>
|
||||
<input type="hidden" name="fo_id" value="<?php echo $fo_id?>"/>
|
||||
<input type="hidden" name="callback_func" value="<?php echo $callback_func?>"/>
|
||||
|
||||
<div id="popBody">
|
||||
|
||||
<div class="calendar">
|
||||
<div class="yymm">
|
||||
<div class="yy">
|
||||
<a href="./calendar.php?fo_id=<?=$fo_id?>&year=<?=$year?>&month=<?=$month?>&method=prev_year&callback_func=<?=$callback_func?>" class="left"><img src="./images/buttonLeft2.gif" alt="prev" width="11" height="11" /></a><?=$year?><a href="./calendar.php?fo_id=<?=$fo_id?>&year=<?=$year?>&month=<?=$month?>&method=next_year&callback_func=<?=$callback_func?>" class="right"><img src="./images/buttonRight2.gif" alt="next" width="11" height="11" /></a>
|
||||
<a href="./calendar.php?fo_id=<?php echo $fo_id?>&year=<?php echo $year?>&month=<?php echo $month?>&method=prev_year&callback_func=<?php echo $callback_func?>" class="left"><img src="./images/buttonLeft2.gif" alt="<?php echo $year - 1?>" width="11" height="11" /></a><?php echo $year?><a href="./calendar.php?fo_id=<?php echo $fo_id?>&year=<?php echo $year?>&month=<?php echo $month?>&method=next_year&callback_func=<?php echo $callback_func?>" class="right"><img src="./images/buttonRight2.gif" alt="<?php echo $year + 1?>" width="11" height="11" /></a>
|
||||
</div>
|
||||
<div class="mm">
|
||||
<p><?=date("M", mktime(0,0,0,$month,1,$year))?></p>
|
||||
<a href="./calendar.php?fo_id=<?=$fo_id?>&year=<?=$year?>&month=<?=$month?>&method=prev_month&callback_func=<?=$callback_func?>" class="left"><img src="./images/buttonLeft2.gif" alt="prev" width="11" height="11" /></a><span><?=$month?></span><a href="./calendar.php?fo_id=<?=$fo_id?>&year=<?=$year?>&month=<?=$month?>&method=next_month&callback_func=<?=$callback_func?>" class="right"><img src="./images/buttonRight2.gif" alt="next" width="11" height="11" /></a>
|
||||
<p><?php echo $monthLongName[$month]?></p>
|
||||
<a href="./calendar.php?fo_id=<?php echo $fo_id?>&year=<?php echo $year?>&month=<?php echo $month?>&method=prev_month&callback_func=<?php echo $callback_func?>" class="left"><img src="./images/buttonLeft2.gif" alt="prev" width="11" height="11" /></a><span><?php echo $month?></span><a href="./calendar.php?fo_id=<?php echo $fo_id?>&year=<?php echo $year?>&month=<?php echo $month?>&method=next_month&callback_func=<?php echo $callback_func?>" class="right"><img src="./images/buttonRight2.gif" alt="next" width="11" height="11" /></a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="go">
|
||||
<input type="text" name="year" class="inputTypeY" value="<?=$year?>" />
|
||||
<input type="text" name="month" class="inputTypeM" value="<?=$month?>" />
|
||||
<input type="image" src="./images/buttonGo.gif" alt="Go" />
|
||||
<select name="year" class="selectTypeY" onchange="submit()">
|
||||
<? for($i = $max_year; $i >= $min_year; $i--):?>
|
||||
<option value="<?php echo $i?>" <?php echo $year == $i? "selected":""?> class="<?php echo $i%10?($i%2?"select_color1":"select_color2"):"select_color10"?>"><?php echo $i?></option>
|
||||
<?endfor?>
|
||||
</select>
|
||||
<select name="month" class="selectTypeM" onchange="submit()">
|
||||
<? for($i = 1; $i <= 12; $i++):?>
|
||||
<option value="<?php echo $i?>" <?php echo $month == $i? "selected":""?> class="<?php echo $i%2?"select_color1":"select_color2"?>"><?php echo sprintf("%02d",$i)?></option>
|
||||
<?endfor?>
|
||||
</select>
|
||||
</div>
|
||||
<br /><br />
|
||||
<center><a href="./calendar.php" class="button"><span>Go Today</span></a></center>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="dd">
|
||||
|
||||
<tr>
|
||||
<?for($y = 0; $y < 7; $y++) {?>
|
||||
<td class="<?php echo $y==0?"sun":($y==6?"sat":"")?>"><?php echo $dayName[$y]?></td>
|
||||
<?}?>
|
||||
</tr>
|
||||
<?php
|
||||
for($i=0;$i<6;$i++) {
|
||||
//1주~6주
|
||||
for($i = 0; $i < 6; $i++) {
|
||||
?>
|
||||
<tr class="<?if($i==0){?>first<?}elseif($i==5){?>last<?}?>">
|
||||
<tr class="<?if($i == 0){?>first<?}elseif($i == 5){?>last<?}?>">
|
||||
<?php
|
||||
for($j=0;$j<7;$j++) {
|
||||
//요일
|
||||
for($j = 0; $j < 7; $j++) {
|
||||
$m = $month;
|
||||
$y = $year;
|
||||
|
||||
$cell_no = $i*7 + $j;
|
||||
$cell_no = $i * 7 + $j;
|
||||
|
||||
if($cell_no < $start_week) {
|
||||
$day = $before_month_month_day + $cell_no - $start_week + 1;
|
||||
$m = $month - 1;
|
||||
if($m<1) {
|
||||
if($m < 1) {
|
||||
$m = 12;
|
||||
$y = $year - 1;
|
||||
}
|
||||
} else {
|
||||
|
||||
$day = $cell_no - $start_week +1;
|
||||
$day = $cell_no - $start_week + 1;
|
||||
$m = $month;
|
||||
|
||||
if($day > $month_day) {
|
||||
$day = $day - $month_day;
|
||||
$m = $month + 1;
|
||||
if($m>12) {
|
||||
if($m >12 ) {
|
||||
$m = 1;
|
||||
$y = $year-1;
|
||||
$y = $year - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($j==0) $class_name = "sun";
|
||||
if($j == 0) $class_name = "sun";
|
||||
elseif($j == 6) $class_name = "sat";
|
||||
else $class_name= "";
|
||||
|
||||
$date = date("Y. m. d", mktime(0,0,0,$m, $day, $y));
|
||||
$date_str = date("Ymd", mktime(0,0,0,$m, $day, $y));
|
||||
$date = $y.". ".sprintf("%02d", $m).". ".sprintf("%02d", $day);
|
||||
$date_str = $y.sprintf("%02d", $m).sprintf("%02d", $day);
|
||||
|
||||
?>
|
||||
<td class="<?=$class_name?>">
|
||||
<?if($m==$month){?>
|
||||
<?if(date("Ymd")==$date_str){?><strong><?}?>
|
||||
<?if($day){?><a href="#" onclick="selectDate('<?=$date?>','<?=$date_str?>','<?=$callback_func?>');return false;"><?=$day?></a><?}else{?> <?}?>
|
||||
<td class="<?php echo $class_name?>" <?if($day){?> onclick="selectDate('<?php echo $date?>','<?php echo $date_str?>','<?php echo $callback_func?>')"<?}?>>
|
||||
<?if($m == $month){?><?if(date("Ymd")==$date_str){?><strong><?}?>
|
||||
<?if($day){?><?php echo $day?><?}else{?> <?}?>
|
||||
<?if(date("Ymd")==$date_str){?></strong><?}?>
|
||||
<?}else{?>
|
||||
<span class="disable"><?if($day){?><a href="#" onclick="selectDate('<?=$date?>','<?=$date_str?>','<?=$callback_func?>');return false;"><?=$day?></a><?}else{?> <?}?></span>
|
||||
<span class="disable"><?if($day){?><?php echo $day?><?}else{?> <?}?></span>
|
||||
<?}?>
|
||||
</td>
|
||||
<?
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div id="popFooter" class="tCenter">
|
||||
<a href="#" onclick="window.close();" class="button"><span>close</span></a>
|
||||
|
|
|
|||
|
|
@ -2,32 +2,37 @@
|
|||
|
||||
body { margin:0; padding:0; }
|
||||
|
||||
#popup_content { width:370px; overflow:hidden;}
|
||||
#popHeadder { width:370px; }
|
||||
#popBody { width:350px; }
|
||||
#popFooter { width:370px; }
|
||||
#popup_content { width:500px; overflow:hidden;}
|
||||
#popHeadder { width:500px; }
|
||||
#popBody { width:480px; }
|
||||
#popFooter { width:500px; }
|
||||
|
||||
#popBody .calendar { width:350px; border:1px solid #c1c0bd; border-left:none; border-right:none; background:#f5f5f5; overflow:hidden; position:relative;}
|
||||
#popBody .calendar { width:480px; border:1px solid #c1c0bd; border-left:none; border-right:none; background:#f5f5f5; overflow:hidden; position:relative;}
|
||||
#popBody .calendar .yymm { width:143px; float:left;}
|
||||
#popBody .calendar .yymm .yy { padding:9px 0 6px 0; text-align:center; border-bottom:1px solid #ededed; margin:0 15px; font:bold 1.2em Tahoma; color:#444444;}
|
||||
#popBody .calendar .yymm .yy { padding:9px 0 6px 0; text-align:center; border-bottom:1px solid #ededed; margin:0 15px; font:bold 1.5em Tahoma; color:#444444;}
|
||||
#popBody .calendar .yymm .mm { margin:0 15px; border-top:1px solid #ffffff; border-bottom:1px solid #ededed; padding:10px 0 7px 0; text-align:center;}
|
||||
#popBody .calendar .yymm .mm p { color:#969696; font:1.6em "Times New Roman";}
|
||||
#popBody .calendar .yymm .mm span { font:4em "Times New Roman"; color:#158692; vertical-align:middle;}
|
||||
#popBody .calendar .yymm .go { padding:7px 0 0 0; margin:0 15px; text-align:center; border-top:1px solid #ffffff;}
|
||||
#popBody .calendar .yymm .go { padding:7px 0 0 0; margin:0px 15px; text-align:center; border-top:1px solid #ffffff; display:inline;}
|
||||
#popBody .calendar .yymm .go * { vertical-align:middle;}
|
||||
#popBody .calendar .yymm .go .selectTypeY { width:60px;}
|
||||
#popBody .calendar .yymm .go .selectTypeM { width:45px;}
|
||||
#popBody .calendar .yymm .go .inputTypeY { border:1px solid #c9c9c9; text-align:center; font:.9em Tahoma; color:#282828; width:31px; height:16px;}
|
||||
#popBody .calendar .yymm .go .inputTypeM { border:1px solid #c9c9c9; text-align:center; font:.9em Tahoma; color:#282828; width:20px; height:16px;}
|
||||
#popBody .calendar .yymm .left { vertical-align:middle; margin-right:14px;}
|
||||
#popBody .calendar .yymm .right { vertical-align:middle; margin-left:14px;}
|
||||
#popBody .calendar .yymm .left img,
|
||||
#popBody .calendar .yymm .right img { vertical-align:middle; position:relative; top:2px;}
|
||||
#popBody .calendar .dd { float:left; width:207px; background:#ffffff; border-left:10px solid #ffffff;}
|
||||
#popBody .calendar .dd td { border-bottom:1px solid #ededed; height:32px; text-align:center; color:#636363; font:.9em Tahoma;}
|
||||
#popBody .calendar .dd td a { color:#636363; font:.9em Tahoma;}
|
||||
#popBody .calendar .dd { float:left; width:337px; background:#ffffff; border-left:10px solid #ffffff;}
|
||||
#popBody .calendar .dd td { border-bottom:1px solid #ededed; height:40px; text-align:center; color:#636363; font:1em Tahoma; cursor:pointer; width:14%;}
|
||||
#popBody .calendar .dd td:hover { background:#eeeeee;}
|
||||
#popBody .calendar .dd td strong { text-decoration:underline;}
|
||||
#popBody .calendar .dd td strong a { text-decoration:underline;}
|
||||
#popBody .calendar .dd td.sun { color:#c95b53;}
|
||||
#popBody .calendar .dd td.sun a { color:#c95b53;}
|
||||
#popBody .calendar .dd td.sat { color:#5378C9;}
|
||||
#popBody .calendar .dd .first { height:35px;}
|
||||
#popBody .calendar .dd .last td { height:35px; border-bottom:none;}
|
||||
#popBody .calendar .dd td .disable a { color:#CCCCCC; }
|
||||
#popBody .calendar .dd td .disable { color:#CCCCCC; }
|
||||
|
||||
#popBody .calendar .select_color1 {background:#ffffff;color:#000000;}
|
||||
#popBody .calendar .select_color2 {background:#eeeeee;color:#000000;}
|
||||
#popBody .calendar .select_color10 {background:#ffff00;color:#000000;}
|
||||
Loading…
Add table
Add a link
Reference in a new issue