|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/event_calendar/ |
Upload File : |
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="libary/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.boxdisplay {
height: 100px;
width: 150px;
text-align:center;
float: left;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 12px;
font-weight: normal;
color: #000;
text-decoration: none;
}
.boxdisplay_small {
width: 120px;
text-align:left;
float: left;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 12px;
font-weight: normal;
color: #000;
text-decoration: none;
}
-->
</style>
</head>
<script language="javascript1.1">
function ShowPopup(parameter){
var xval=document.form1;
for(i=0;i<xval.length;i++){
if(xval[i].type=="radio"){
if(xval[i].checked){
str=xval[i].value;
i=xval.lenght;
}
}
}
url='public/detail.php?'+parameter+'&view='+str
MM_openBrWindow(url , '','status=yes,scrollbars=no,width=640,height=525')
//MM_openBrWindow('manage_data.php?'+parameter+'&view='+str+' ,status=yes,scrollbars=no,width=640,height=525');
}
</script>
<body>
<?php
$jump = $_GET["jump"];
if($jump != ""){
$df = explode("/", $jump);
$today = $df[0];
$dfMonth = $df[1];
$dfYear = $df[2];
}
/* ฟังก์ชั่น LastDay() ใช้สำหรับหาวันที่สุดท้ายของเดือน/ปีที่ระบุ หรือกล่าวอีกนัยหนึ่งคือหาว่าเดือน/ปีที่ระบุนั้นมีกี่วัน */
function LastDay($m, $y) {
for ($i=29; $i<=32; $i++) { if(checkdate($m, $i, $y) == 0) { return $i - 1; } }
}
/* $diffHour และ $diffMinute คือตัวแปรที่ใช้เก็บจำนวนชั่วโมงและจำนวนนาทีที่ แตกต่างกันระหว่างเครื่องไคลเอนต์กับเครื่องเซิร์ฟเวอร์ ตามลำดับ เช่นถ้าเวลาของ
เครื่องไคลเอ็นต์เร็วกว่าเวลาของเครื่องเซิร์ฟเวอร์ 11 ชั่วโมง 15 นาที ก็ให้กำหนด $diffHour เป็น 11 และกำหนด $diffMinute เป็น 15 ในที่นี้ผู้เขียนถือว่า
เครื่องเซิร์ฟเวอร์กับเครื่องไคลเอ็นต์มีเวลาตรงกัน */
$diffHour = 0;
$diffMinute = 0;
//echo date("Y-m-d");
if ($dfMonth == "") {
$calTime = getdate(date(mktime(date("H") + $diffHour, date("i") + $diffMinute)));
//echo "<pre>";
//print_r($calTime);
$today = $calTime["mday"]; //วันที่
$month = $calTime["mon"]; //เดือน
$year = $calTime["year"]; //ปี
} else {
/* กรณีที่ระบุให้แสดงปฏิทินของเดือน/ปีหนึ่งๆนั้น จะมีการส่งตัวแปร $today, $dfMonth และ $dfYear ผ่านมาทาง query string ด้วย */
if ($dfMonth == 0) {
/* ถ้าตัวแปร $dfMonth เป็น 0 เราจะแสดงปฏิทินของเดือนธันวาคมของปีที่น้อย กว่าปีที่กำลังแสดงอยู่ */
$dfMonth = 12;
$dfYear = $dfYear - 1;
} elseif ($dfMonth == 13) {
/* ถ้าตัวแปร $dfMonth เป็น 13 เราจะแสดงปฏิทินของเดือนมกราคมของปีที่มากกว่าปีที่กำลังแสดงอยู่ */
$dfMonth = 1;
$dfYear = $dfYear + 1;
}
//สร้างวัน/เวลาของเดือนและปีที่ผู้ใช้ระบุ เก็บไว้ในตัวแปร $calTime
$calTime = getdate(date(mktime((date("H") + $diffHour), (date("i") + $diffMinute), 0, $dfMonth, $today, $dfYear)));
$today = $calTime["mday"]; //วันที่
$month = $calTime["mon"]; //เดือน
$year = $calTime["year"]; //ปี
}
/* เรียกฟังก์ชั่น LastDay() ซึ่งเป็นฟังก์ชั่นที่เราสร้างขึ้นมาเอง เพื่อหา "จำนวนวัน" ของเดือนและปีที่จะแสดงปฏิทิน โดยเก็บไว้ในตัวแปร $Lday */
$Lday = LastDay($month, $year);
//เก็บ timestamp ของวันที่ 1 ของเดือนที่จะแสดงปฏิทิน ไว้ในตัวแปร $FTime
$FTime = getdate(date(mktime(0, 0, 0, $month, 1, $year)));
//เก็บ "วันในสัปดาห์" (จันทร์, อังคาร ฯลฯ) ของวันที่ 1 ของเดือนไว้ในตัวแปร $wday
$wday = $FTime["wday"];
//สร้างตัวแปรชนิดอาร์เรย์เก็บชื่อเดือนภาษาไทย
$thmonthname = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
$month_next = $month + 1 ;
$month_prev = $month - 1 ;
$jump_next = $today."/".$month_next."/".$year;
$jump_prev = $today."/".$month_prev."/".$year;
/*สร้างตัวแปรที่เอาไว้ตรวจสอบวันภายในเดือนที่แสดง ถ้ามีข้อมูลก็ให้ทำ link */
if($today != ""){$sqDay = add_zero($today);}
if($dfMonth != ""){ $sqMonth = add_zero($dfMonth); } else {$sqMonth = add_zero($month);}
if($dfYear != ""){ $sqYear = $dfYear; } else {$sqYear = $year;}
/*Query ข้อมูลจาก Database*/
$sql_chk = $sqYear."-".$sqMonth."-__";
//$sql_dd = "select $cal_table_edate.edate from $cal_table where $cal_table_edate.edate like '$sql_chk' $cal_sql";
$sql_dd = "select $cal_table_edate.edate from $cal_table where $cal_table_edate.edate like '$sql_chk'";
//echo $sql_dd;
$result = mysql_query($sql_dd)or die("Query Line " . __LINE__ . " Error<hr>".mysql_error());
$row = mysql_num_rows($result);
if($row != 0){
while($rs = mysql_fetch_assoc($result)){
$arr = explode("-", $rs[edate]);
$rday = remove_zero($arr[2]);
$arr_day[$rday] = $rday;
}
}
mysql_free_result($result);
$img_l = "images/left.gif";
if(!file_exists($img_l)) {$img_l = "images/left.gif"; }
$img_r = "images/right.gif";
if(!file_exists($img_r)) {$img_r = "images/right.gif"; }
$img_c = "images/calendar.gif";
if(!file_exists($img_c)) {$img_c = "images/calendar.gif"; }
$sqlpersonal="SELECT
epm_staff.prename
, epm_staff.staffname
, epm_staff.staffsurname
, epm_staff.title
, emp_staff_priority.indexid,epm_staff.image
FROM
rayong_eoffice.epm_staff
INNER JOIN rayong_eoffice.emp_staff_priority
ON (epm_staff.staffid = emp_staff_priority.staffid)
WHERE (emp_staff_priority.indexid is not null) ORDER BY emp_staff_priority.indexid";
$result = mysql_query($sqlpersonal)or die("Query Line " . __LINE__ . " Error<hr>".mysql_error());
$row = mysql_num_rows($result);
if($row != 0){
echo "<table width=\"100%\" align=\"center\" ><tr><td>";
while($rs = mysql_fetch_assoc($result)){
$img="../../images/personal/".$rs['image'];
if(!file_exists(img)){
$img="../../images/personal/no.jpg";
}
$strname=$rs['prename']." " .$rs['staffname']." " .$rs['staffsurname'];
$strposition=$rs['title'];
$imgstr="<img src =$img widht=50 height=50/>";
echo "<div class=\"boxdisplay\">$imgstr<br>$strname<br>$strposition </div>";
}
echo" </td> </tr></table>" ;
}
?>
<table width="100%%">
<tr>
<td align="right">
<form name="form1" action="#">
<table width="517" >
<tr>
<td width="323" align="right" class="day_number"><span class="day_number">
<input name="radio[]" type="radio" id="radio1" value="D" checked>
</span>รายวัน</td>
<td width="97" align="right" class="day_number"><input type="radio" name="radio[]" id="radio1" value="W">
รายสัปดาห์</td>
<td width="81" align="right" class="day_number"><input type="radio" name="radio[]" id="radio1" value="M">
รายเดือน</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td bgcolor="#000000">
<table width="100%" border="0" cellpadding="1" cellspacing="1" align="center">
<tr align="center" bgcolor="#C1E2F8">
<td height="19" width="50" align="center"><a href="?jump=<?=$jump_prev.$cal_kwd?>"><img src="<?=$img_l?>" width="12" height="12" border="0" ></a></td>
<td height="19" width="600" colspan="5" class="normal_blue" align="center"><?php echo " <font class=blue1>".$thmonthname[$month - 1]."</font> <font class=brown1>".($year + 543)."</font>"; ?></td>
<td height="19" width="50" align="center"><a href="?jump=<?=$jump_next.$cal_kwd?>"><img src="<?=$img_r?>" width="12" height="12" border="0"></a></td>
<tr>
<tr align="center" bgcolor="#e3e3e3" class="normal_blue" style="font-weight:bold;">
<td height="19" width="100" class="warn">อา</td>
<td height="19" width="100">จ</td>
<td height="19" width="100">อ</td>
<td height="19" width="100">พ</td>
<td height="19" width="100">พฤ</td>
<td height="19" width="100">ศ</td>
<td height="19" width="100">ส</td>
</tr>
<?php
$iday = 1;
//แสดงแถวแรกของปฏิทิน
//echo $iday." == ".$today;
for ($i=0; $i<=6; $i++) {
if ($i < $wday) { /*แสดงเซลล์ว่างก่อนวันที่ 1 ของเดือน*/
if ($i == 0) { /*กรณีที่เป็นวันอาทิตย์*/ $class ="class=\"warn\""; } else { /*กรณีที่เป็นวันอื่นๆที่ไม่ใช่วันอาทิตย์*/ $class ="class=\"normal\""; }
echo "<td width=\"100\" height=\"100\" align=\"center\" $class bgcolor=\"#FFFFCC\"> </td>\n";
} else {
//แสดงวันที่ในแถวแรกของปฏิทิน
if($iday == $arr_day[$iday]) {
$class = " class=\"brown\" bgcolor=\"#B5D1FF\" style=\"font-weight:bold;\" ";
//$class = $class." onClick=\"delayhide()\" ";
$sql_date = $sqYear."-".$sqMonth."-".add_zero($arr_day[$iday]);
// แสดงรายการในหน้าปฏิทิน
// $strSQL_list = "SELECT epm_staff.title, Count(function_mgr.staffid) as n_staffid,function_mgr.edate FROM epm_staff Inner Join function_mgr ON epm_staff.staffid = function_mgr.staffid WHERE function_mgr.edate LIKE '$sql_date' GROUP BY function_mgr.staffid";
$strSQL_list="SELECT function_mgr.id, epm_staff.prename , epm_staff.staffname , epm_staff.staffsurname , epm_staff.title , epm_staff.image , function_mgr.event_name
, function_mgr.event_place , function_mgr.edate , function_mgr.etime
FROM rayong_eoffice.epm_staff INNER JOIN rayong_eoffice.main_menu_owner ON (epm_staff.staffid = main_menu_owner.owner_id)
INNER JOIN rayong_eoffice.function_mgr ON (function_mgr.staffid = epm_staff.staffid) WHERE function_mgr.edate LIKE '$sql_date'
GROUP BY epm_staff.prename, epm_staff.staffname, epm_staff.staffsurname, epm_staff.title, epm_staff.image , function_mgr.event_name
, function_mgr.event_place,function_mgr.id ORDER BY function_mgr.edate,function_mgr.etime";
$result_list = mysql_query($strSQL_list);
while($rsli = mysql_fetch_assoc($result_list)){
//$data_sql.=" -".$rsli[title]."($rsli[n_staffid]งาน)"."<br>";
$jobid= $rsli['id'];
$jobstr=$rsli['event_name'] ;
$jobplace=$rsli['event_place'] ;
$img="../../images/personal/".$rsli['image'];
if(!file_exists(img)){
$img="../../images/personal/no.jpg";
}
$imgstr="<img src =$img widht=50 height=50/>";
$data_sql .= "<div class=\"boxdisplay_small\">$imgstr<a href=\"#\" class=\"style1\" onClick=\"ShowPopup('action=limit2&edate=$arr_day[$iday]/$sqMonth/$sqYear&xday=$i&jobid=$jobid')\">$jobstr</a> $jobplace<br><br><div>";
// $data_sql .= "<div class=\"boxdisplay_small\">$imgstr<a href=\"#\" class=\"style1\" onClick=\"ShowPopup('action=schedule&jump=$arr_day[$iday]/$sqMonth/$sqYear$cal_kwd&xday=$i&jobid=$jobid')\">$jobstr</a> $jobplace<br><br><div>";
}
$link = "y";
} elseif($iday == $today) { $class = " class=\"blue\" style=\"font-weight:bold;\""; $link = "n";}
elseif($i == 0 && ($iday != $today)) { /*กรณีที่เป็นวันอาทิตย์ และไม่ใช่วันปัจจุบัน*/ $class ="class=\"warn\""; $link = "n";}
else { $class ="class=\"normal\""; $link = "n";}
//if($link == "y"){ $show_event = "<a href=?jump=".$arr_day[$iday]."/".$sqMonth."/".$sqYear.$cal_kwd." class='link' style='text-decoration:none;'>$iday$data_sql</a>"; } else { $show_event = $iday ; }
if($link == "y"){
$show_event = $iday."<br>".$data_sql;//"<a href=\"#\" class=\"style1\" onClick=\"MM_openBrWindow('manage_data.php?action=schedule&jump=$arr_day[$iday]/$sqMonth/$sqYear$cal_kwd&xday=$i','','status=yes,scrollbars=no,width=640,height=525')\">$iday<br>$data_sql</a>";
} else {
$show_event = $iday ;
}
$data_sql = ""; // ล้างค่าตัวแปรเพื่อเขียนรายการใหม่ในวันถัดไป
echo "<td width=\"100\" height=\"100\" align=\"left\" valign=\"top\" $class bgcolor=\"#FFFFFF\">".$show_event."</td>\n";
$iday++;
}
}
$link = "";
//แสดงแถวที่เหลือของปฏิทิน (หลังจากแสดงแถวแรกไปแล้ว จะเหลืออย่างมาก 5 แถว)
for ($j=0; $j<=4; $j++) {
if ($iday <= $Lday) {
echo "<tr>\n";
for ($i=0; $i<=6; $i++) {
if ($iday <= $Lday) {
if($iday == $arr_day[$iday]) {
$class = " class=\"brown\" bgcolor=\"#B5D1FF\" style=\"font-weight:bold;\" ";
// $class = $class." onClick=\"delayhide()\" ";
$sql_date = $sqYear."-".$sqMonth."-".add_zero($arr_day[$iday]);
//$strSQL_list = "SELECT epm_staff.title, Count(function_mgr.staffid) as n_staffid,function_mgr.edate FROM epm_staff Inner Join function_mgr ON epm_staff.staffid = function_mgr.staffid WHERE function_mgr.edate LIKE '$sql_date' GROUP BY function_mgr.staffid";
$strSQL_list="SELECT function_mgr.id, epm_staff.prename , epm_staff.staffname , epm_staff.staffsurname , epm_staff.title , epm_staff.image , function_mgr.event_name
, function_mgr.event_place , function_mgr.edate , function_mgr.etime
FROM rayong_eoffice.epm_staff INNER JOIN rayong_eoffice.main_menu_owner ON (epm_staff.staffid = main_menu_owner.owner_id)
INNER JOIN rayong_eoffice.function_mgr ON (function_mgr.staffid = epm_staff.staffid) WHERE function_mgr.edate LIKE '$sql_date'
GROUP BY epm_staff.prename, epm_staff.staffname, epm_staff.staffsurname, epm_staff.title, epm_staff.image , function_mgr.event_name
, function_mgr.event_place,function_mgr.id ORDER BY function_mgr.edate,function_mgr.etime";
$result_list = mysql_query($strSQL_list);
while($rsli = mysql_fetch_assoc($result_list)){
//$data_sql.=" -".$rsli[title]."($rsli[n_staffid]งาน)"."<br>";
$jobid= $rsli['id'];
$jobstr=$rsli['event_name'] ;
$jobplace=$rsli['event_place'] ;
$img="../../images/personal/".$rsli['image'];
if(!file_exists(img)){
$img="../../images/personal/no.jpg";
}
$imgstr="<img src =$img widht=50 height=50/>";
// $data_sql .= "<div class=\"boxdisplay_small\">$imgstr<a href=\"#\" class=\"style1\" onClick=\"ShowPopup('action=schedule&jump=$arr_day[$iday]/$sqMonth/$sqYear$cal_kwd&xday=$i&jobid=$jobid')\">$jobstr</a> $jobplace<br><br><div>";
$data_sql .= "<div class=\"boxdisplay_small\">$imgstr<a href=\"#\" class=\"style1\" onClick=\"ShowPopup('action=limit2&edate=$arr_day[$iday]/$sqMonth/$sqYear&xday=$i&jobid=$jobid')\">$jobstr</a> $jobplace<br><br><div>";
}
$link = "y";
} elseif($iday == $today) { $class = " class=\"blue\" style=\"font-weight:bold;\""; $link = "n";}
elseif ($i == 0 && ($iday != $today)) { $class = "class=\"warn\""; $link = "n";}
else {$class = "class=\"normal\""; $link = "n";}
if($link == "y"){
$show_event = $iday."<br>".$data_sql;//"<a href=\"#\" class=\"style1\" onClick=\"MM_openBrWindow('manage_data.php?action=schedule&jump=$arr_day[$iday]/$sqMonth/$sqYear$cal_kwd&xday=$i','','status=yes,scrollbars=no,width=640,height=525')\">$data_sql</a>";
} else {
$show_event = $iday ;
} $data_sql= "";
echo "<td width=\"100\" height=\"100\" align=\"left\" valign=\"top\" $class bgcolor=\"#FFFFFF\">"
.$show_event.
"</td>\n";
} else {
echo "<td width=\"100\" height=\"100\" align=\"left\" class=\"normal\" bgcolor=\"#FFFFCC\"> </td>\n";
}
$iday++;
}
echo "</tr>\n";
} else {
break;
}
}
?>
<tr bgcolor="#ffffff" align="center">
<td height="25" colspan="7" class="normal_black">
<div align="center" id="Add_event" style="height:20px; width: 150px; border: 1px solid black; background: #f8f8f8; padding: 1px 5px; cursor:hand;" onClick="window.location.replace('<?=$PHP_SELF.$cdate_kwd?>')"><img src="<?=$img_c?>" width="16" height="16" align="absmiddle" border="0"> เดือนปัจจุบัน</div></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>