Path : /var/www/html/smart_kpp2_bk17 มีค 69/modules/meeting/main/
File Upload :
Current File : /var/www/html/smart_kpp2_bk17 มีค 69/modules/meeting/main/calMonthPrint.php

<script type="text/javascript" src="./css/js/calendarDateInput.js"></script> 
<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
//require ( "include/functions.php"); 
require ( "language/lang-thai.php");
//include ("include/popup.js");
require_once "modules/meeting/time_inc.php";	

$user=$_SESSION['login_user_id'];
//กรณีเลือกแสดงเฉพาะห้องประชุม
if(isset($_REQUEST['room_index'])){
$room_index=$_REQUEST['room_index'];
}
else{
$room_index="";
}
?>
<script language='javascript'>
//<!–
function printContentDiv(content){
var printReady = document.getElementById(content);
//var txt= 'nn';
var txt= '';

if (document.getElementsByTagName != null){
var txtheadTags = document.getElementsByTagName('head');
if (txtheadTags.length > 0){
var str=txtheadTags[0].innerHTML;
txt += str; // str.replace(/funChkLoad();/ig, ” “);
}
}
//txt += 'nn';
if (printReady != null){
txt += printReady.innerHTML;
}
//txt +='nn';
var printWin = window.open();
printWin.document.open();
printWin.document.write(txt);
printWin.document.close();
printWin.print();
}
// –>
</script>

<?php
//ส่วนหัว
echo "<br />";
if(!(($index==1) or ($index==2) or ($index==5))){
	echo "<table width='100%' border='0' align='center'>";
	echo "<tr align='center'><td><font color='#006666' size='3'><strong>ปฏิทินทะเบียนจองห้องประชุม</strong></font></td></tr>";
	echo "</table>";
}
//ส่วนฟอร์ม
if(!(($index==2) or ($index==5))){
echo "<form  name='frm1'>";
echo "<table width=100%><tr><td align='left' width='50%'>";
echo " <INPUT TYPE='button' name='smb' value='กลับหน้าหลัก' onclick='location.href=\"?option=meeting&task=main/calMonth\"'>&nbsp;&nbsp;";
?>
<a href="javascript:printContentDiv('lblPrint');"><img src="images/my-icons/print.png" border='0' height='75'></a>
<?php
echo "</td><td align='right'>";
echo "&nbsp;<Select  name='room_index' size='1'>";
echo  '<option value ="" >เลือกห้องประชุม</option>' ;
	$sql_room = "select * from meeting_room where active='1' order by id";
	$dbquery_room = mysqli_query($connect,$sql_room);
	While ($result_room = mysqli_fetch_array($dbquery_room )){ 
		if ($room_index==$result_room ['room_code']){
			echo "<option value=$result_room[room_code]  selected>$result_room[room_name]</option>"; 
		}else{
			echo "<option value=$result_room[room_code]>$result_room[room_name]</option>"; 
		}
	}
echo "</select>";
echo "&nbsp;<INPUT TYPE='button' name='smb' value='เลือก' onclick='goto_url2(1)'>";
echo "</td></tr></table>";
echo "</form>";

	if (empty($Date)) {
		$Date = Date("m-d-Y");
	}	
	$Date_Array = explode("-", $Date);
	if ($Date_Array[2] < 1970)
		print("ERROR! System can not interpret dates befor 01/01/1970");
        else {
			$Date = mktime(0, 0, 0, $Date_Array[0], $Date_Array[1], $Date_Array[2]);  //0=เดือน 1=วัน 2=ปี

			##########     ส่วนหัว     |-------------------------------------------
			$Prev_Month = mktime(0, 0, 0, $Date_Array[0] - 1, 1, $Date_Array[2]);
			$Prev_Date = Date("m-d-Y",$Prev_Month);
			$Next_Month = mktime(0, 0, 0, $Date_Array[0] + 1, 1, $Date_Array[2]);
			$Next_Date = Date("m-d-Y",$Next_Month);
			$month_priv = $Date_Array[0]-1;
			$month_next = $Date_Array[0]+1;

			if($room_index=='')  {			//ลิงค์หน้าปฏิทินหลัก
				print("\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tr><td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr height=\"20\">");
				##########     Print Title : เดือนก่อนนี้     |-------------------------------------------
				print("<td width=\"50%\" align=\"left\"><a href=\"?option=meeting&task=main/calMonthPrint&room_index=$room_index&Date=$Prev_Date\"><img src=\"images/arr_circle_prev42-42.gif\" border=0 valign=middle>&nbsp; $_month_priv</a></td>");

				##########     Print Title : เดือนถัดไป     |-------------------------------------------
				print("<td width=\"50%\" align=\"right\"><a href=\"?option=meeting&task=main/calMonthPrint&room_index=$room_index&Date=$Next_Date\">$_month_next&nbsp;<img src=\"images/arr_circle_next42-42.gif\" border=0 valign=middle></a></td>");
				print("</TR></TABLE>");

?>
<div id="lblPrint">
<?php
				##########     Print Title : ประจำเดือน     |-------------------------------------------
				print("\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tr><td align=center>");
				print("<B>");
				print("ประจำเดือน ");
				print(getMonthName($Date));
				print(" พ.ศ. ");
				print($Date_Array[2]+543);
				print(" / ");
				print(getMonthEnName($Date));
				print(" ".$Date_Array[2]."");
				print("</B>");
				print("</TD></tr></table>");


			}else{		//ลิงค์หน้าปฏิทินของห้องประชุม
				print("\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tr><td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr height=\"20\">");

				##########     Print Title : เดือนก่อนนี้     |-------------------------------------------
				print("<td width=\"50%\" align=\"left\"><a href=\"?option=meeting&task=main/calMonthPrint&room_index=$room_index&Date=$Prev_Date\"><img src=\"images/arr_circle_prev42-42.gif\" border=0>&nbsp; $_month_priv</a></td>");
				##########     Print Title : เดือนถัดไป     |-------------------------------------------
				print("<td width=\"50%\" align=\"right\"><a href=\"?option=meeting&task=main/calMonthPrint&room_index=$room_index&Date=$Next_Date\">$_month_next&nbsp;<img src=\"images/arr_circle_next42-42.gif\" border=0></a></td>");
				print("</TR></TABLE>");
?>
<div id="lblPrint">
<?php
				##########     Print Title : ประจำเดือน     |-------------------------------------------
				print("\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tr><td align=center>");
				print("<B>");
				print("ประจำเดือน ");
				print(getMonthName($Date));
				print(" พ.ศ. ");
				print($Date_Array[2]+543);
				print(" / ");
				print(getMonthEnName($Date));
				print(" ".$Date_Array[2]."");
				print("</B>");
				print("</TD></tr></table>");

			}

			/**** Get the Day (Integer) for the first day in the month */
			$First_Day_of_Month_Date = mktime(0, 0, 0, $Date_Array[0], 1, $Date_Array[2]);
			$Day_of_First_Week = Date("w",$First_Day_of_Month_Date);
			/**** Find the last day of the month */
			$Month = Date("m",$Date);
			$day = 27;
			do {
				$End_of_Month_Date = mktime(0, 0, 0, $Date_Array[0], $day, $Date_Array[2]);
				$Test_Month = Date("m",$End_of_Month_Date);
				$day += 1;
			} while ( $Month == $Test_Month );
				$Last_Day = $day - 2;

				/**** Get todays date */
				$Today_d = Date("d");
				$Today_m = Date("m");
				$Today_y = Date("Y");

				##########     กำหนดค่าเดือน     |-------------------------------------------
				if ($Date_Array[0]=='01'){
					$Date_Arrayx[0]='1'; $imgcalendar="<img src=\"images/calendar/1.png\" border=0>";
				}elseif ($Date_Array[0]=='02'){
					$Date_Arrayx[0]='2'; $imgcalendar="<img src=\"images/calendar/2.png\" border=0>";
				}elseif ($Date_Array[0]=='03'){
					$Date_Arrayx[0]='3'; $imgcalendar="<img src=\"images/calendar/3.png\" border=0>";
				}elseif ($Date_Array[0]=='04'){
					$Date_Arrayx[0]='4'; $imgcalendar="<img src=\"images/calendar/4.png\" border=0>";
				}elseif ($Date_Array[0]=='05'){
					$Date_Arrayx[0]='5'; $imgcalendar="<img src=\"images/calendar/5.png\" border=0>";
				}elseif ($Date_Array[0]=='06'){
					$Date_Arrayx[0]='6'; $imgcalendar="<img src=\"images/calendar/6.png\" border=0>";
				}elseif ($Date_Array[0]=='07'){
					$Date_Arrayx[0]='7'; $imgcalendar="<img src=\"images/calendar/7.png\" border=0>";
				}elseif ($Date_Array[0]=='08'){
					$Date_Arrayx[0]='8'; $imgcalendar="<img src=\"images/calendar/8.png\" border=0>";
				}elseif ($Date_Array[0]=='09'){
					$Date_Arrayx[0]='9'; $imgcalendar="<img src=\"images/calendar/9.png\" border=0>";
				}elseif ($Date_Array[0]=='10'){ $imgcalendar="<img src=\"images/calendar/1.png\" border=0><img src=\"images/calendar/0.png\" border=0>";
				}elseif ($Date_Array[0]=='11'){ $imgcalendar="<img src=\"images/calendar/1.png\" border=0><img src=\"images/calendar/1.png\" border=0>";
				}elseif ($Date_Array[0]=='12'){ $imgcalendar="<img src=\"images/calendar/1.png\" border=0><img src=\"images/calendar/2.png\" border=0>";
				}
				##########     ปฏิทิน     |-------------------------------------------
				echo "<CENTER>".$imgcalendar."<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" style=\"background-attachment: fixed; background-image: url(images/calendar/bg.jpg); background-repeat: no-repeat; background-position: right\">";
				echo "<tr> ";
				echo "<td class=\"weekname\"><hr size=1 color=#ff0000><font color=#ff0000>$_suLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#ffff99><font color=#ffff99>$_moLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#ffc0cb><font color=#ffc0cb>$_tuLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#98fb98><font color=#98fb98>$_weLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#ffa500><font color=#ffa500>$_thLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#87ceeb><font color=#87ceeb>$_frLong</font></td>";
				echo "<td class=\"weekname\"><hr size=1 color=#800080><font color=#ffaaff>$_saLong</font></td>";
				echo "</tr>";
                $day_of_week = 1;

                /**** Previous Greyed month days */
                While ($day_of_week < ($Day_of_First_Week + 1)) {
						##########	     วันในเดือนก่อนนี้     |-------------------------------------------
                        if ($day_of_week == 1) {
                                print("\n<tr >");
                                }
                        $Tmp_Date = mktime(0, 0, 0, $Date_Array[0], 1 - (($Day_of_First_Week + 1) - $day_of_week), $Date_Array[2]);
                        $Tmp_Day = Date("d",$Tmp_Date);
                        print("<TD align=center valign=top class=\"tbcalendar\">$Tmp_Day</TD>");
                        $day_of_week += 1;
                }
                $usedcount = 0;
                $cellcount = 0;

				##########     วันในปฏิทินเดือนปัจจุบันที่เลือก     |-------------------------------------------
				for ($day = 1 ; $day <= $Last_Day ; $day++) {
						if ($day_of_week == 1) {
								##########	     วันในเดือนนี้     |-------------------------------------------
                                print("\n<tr>");
                                }
						#########	ค้นหาวันหยุดราชการ		|-------------------------------------------
						//$db2sql = "select * from ".$prefix."_calholiday where did='$day' AND mid='$Date_Array[0]' AND yid='$Date_Array[2]' ";
						//$rsHoliday = mysqli_query($connect2,$db2sql);
						//$rowHoliday = mysqli_fetch_array($rsHoliday);
						//$num_rowsHoliday = mysqli_num_rows($rsHoliday);

						if	($num_rowsHoliday != 0 ) { 
							$Holiday ="<font color=red><b>หยุดราชการ</b></font> ".$rowHoliday[content]."";
							if (($day == $Today_d) && ($Date_Array[0] == $Today_m) && ($Date_Array[2] == $Today_y))
								##########      วันหยุด - วันที่ปัจจุบันในเดือนนี้     |-------------------------------------------
								print("\n\t<TD valign=top align=top><TABLE width=100% cellpadding=0 cellspacing=0 border=0><TR><TD align=center class=\"dayname\"><img src=\"images/loading.gif\" border=0>$day วันนี้<br>".$Holiday."");
							else
								##########      วันหยุด - วันที่อื่นในเดือนนี้     |-------------------------------------------
								print("\n\t<TD valign=top align=top><TABLE width=100% cellpadding=0 cellspacing=0 border=0><TR><TD align=center class=\"dayname\">$day<br>".$Holiday."");
						}else{ 
							if (($day == $Today_d) && ($Date_Array[0] == $Today_m) && ($Date_Array[2] == $Today_y))
								##########      วันที่ปัจจุบันในเดือนนี้     |-------------------------------------------
								print("\n\t<TD valign=top align=top><TABLE width=100% cellpadding=0 cellspacing=0 border=0><TR><TD align=center class=\"dayname\"><img src=\"images/loading.gif\" border=0>$day วันนี้");
							else
								##########      วันที่อื่นในเดือนนี้     |-------------------------------------------
								print("\n\t<TD valign=top align=center><TABLE width=100% cellpadding=0 cellspacing=0 border=0><TR><TD align=center class=\"dayname\">$day");
							}

			##########		เริ่มต้น -> นำเข้าข้อมูลแสดงในปฏิทินในแต่ละวัน
			##########     ตรวจสอบวันที่ตรงกับวันที่ใช้งาน
			switch ( $day ) {
				case "1" : $day='01' ; break; case "2" : $day='02' ; break; case "3" : $day='03' ; break;
				case "4" : $day='04' ; break;case "5" : $day='05' ; break;case "6" : $day='06' ; break;
				case "7" : $day='07' ; break;case "8" : $day='08' ; break;case "9" : $day='09' ; break;
			}
			$ck_startDate = ($Date_Array[2])."-".$Date_Array[0]."-".$day;
			##########     เลือกฐานข้อมูลทั้งหมด
			##########     แยกแสดงผลการใช้งานเฉพาะห้องประชุมคันใดคันหนึ่ง กับ การใช้งานทั้งหมด
			##########     เลือกฐานข้อมูลแยกจาก ห้องประชุมทั้งหมด $room_index =='' ,เฉพาะห้องประชุม $room_index !='' 
			$sql_room = "select * from meeting_room where active='1' order by id";
			$dbquery_room = mysqli_query($connect,$sql_room);
			While ($result_room = mysqli_fetch_array($dbquery_room))
			{
			$room_ar[$result_room['room_code']]=$result_room['room_name'];
			}
			if($room_index != ''){	 //แสดงการใช้งานเฉพาะห้องประชุมในวันนั้น
				$sqlConfirm = "select meeting_main.id, meeting_main.room, meeting_main.book_date, meeting_main.book_date_end, meeting_main.start_time, meeting_main.finish_time, meeting_main.objective, meeting_main.person_num, meeting_main.other, meeting_main.book_person, meeting_main.rec_date, meeting_main.approve, meeting_main.reason, person_main.name ,person_main.surname from meeting_main left join person_main on meeting_main.book_person = person_main.person_id where meeting_main.room='$room_index' and ('$ck_startDate' BETWEEN meeting_main.book_date AND meeting_main.book_date_end) order by meeting_main.room";
			}else{	//แสดงการใช้งานทั้งหมดในวันนั้น
				$sqlConfirm = "select meeting_main.id, meeting_main.room, meeting_main.book_date, meeting_main.book_date_end, meeting_main.start_time, meeting_main.finish_time, meeting_main.objective, meeting_main.person_num,  meeting_main.other, meeting_main.book_person, meeting_main.rec_date, meeting_main.approve, meeting_main.reason, person_main.name ,person_main.surname from meeting_main left join person_main on meeting_main.book_person = person_main.person_id where '$ck_startDate' BETWEEN meeting_main.book_date AND meeting_main.book_date_end order by meeting_main.room";
			}

			$rsConfirm = mysqli_query($connect,$sqlConfirm);
			$num_rowsConfirm = mysqli_num_rows($rsConfirm);
			$conf = 1;
			if($num_rowsConfirm != '0'){	print("</TD></TR></TABLE>"); }else{ print(" (ว่าง)</TD></TR></TABLE>"); }

			print ("<TABLE width=100% cellpadding=2 border=0>");
			while ($row_rsConfirm = mysqli_fetch_array($rsConfirm)) {
				$id= $row_rsConfirm['id'];
				$room= $row_rsConfirm['room'];
				$start_time=$row_rsConfirm['start_time'];
				//$start_time=number_format($start_time,2);
				$finish_time=$row_rsConfirm['finish_time'];
				//$finish_time=number_format($finish_time,2);
				//$dotx=Strlen($row_rsConfirm['objective']);
				//if($dotx>=150){ $dot="ฯ"; }else{ $dot=""; }
				//$objective=substr($row_rsConfirm['objective'],0,150).$dot;
				$objective=$row_rsConfirm['objective'];
				//$book_date = $row_rsConfirm['book_date'];
				//$book_date_end = $row_rsConfirm['book_date_end'];
				$rec_date = $row_rsConfirm['rec_date'];
				$name= $row_rsConfirm['name'];
				$surname = $row_rsConfirm['surname'];
				if(isset($room_ar[$room])){
				$room_name = $room_ar[$room];
				}
				$approve=$row_rsConfirm['approve'];

			//กำหนดสีประจำสัปดาห์
			if ( $day_of_week == 1 ) $color ="#ffaaaa";	//แดง  #ff4040
			if ( $day_of_week == 2 ) $color ="#fff";	//เหลือง  #ffffd5
			if ( $day_of_week == 3 ) $color ="#fff";	//ชมภู  pink
			if ( $day_of_week == 4 ) $color ="#fff";		//เขียว  #d5ffd5
			if ( $day_of_week == 5 ) $color ="#fff";		//แสด  Orange
			if ( $day_of_week == 6 ) $color ="#fff";		//ฟ้า  #d5ffff
			if ( $day_of_week == 7 ) $color ="#ffaaff";		//ม่วง  #bf80ff
			$color2 = '#FFFFB'; 
switch ( $approve ) {
	case '1' :
		$g="<img src=images/yes.png border='0'>";
		$f="meeting_report" ; $index="1"; 
		break;
	case '2' :
		$g="<img src=images/no.png border='0'>";
		$f="meeting_report" ; $index="1"; 
		break;
	default :
		if( ($row_rsConfirm['book_person']==$user) && ($result['approve']=='') ){
			$color = "#d5ffd5";
			$color2 = "#d5ffd5";
			$g = "";
			$f="meeting" ; $index="2"; 
		}else{
			$color = "#d5ffd5";
			$color2 = "#d5ffd5";
			$g = "<img src=images/loading.gif border='0'> รออนุมัติ";
			$f="meeting_report" ; $index="1"; 
		}
		if(($result_permission['p1']==1) or ($_SESSION['admin_meeting']=="meeting")){
			$color = "#d5ffd5";
			$color2 = "#d5ffd5";
			$g="<img src=images/loading.gif border='0'> รออนุมัติ</a>";
			$f="officer" ; $index="5"; 
		}
	break;
}

				##########     แสดงข้อมูลที่พบ     |-------------------------------------------
				print ("<TR bgcolor=$color onmouseover=\"javascript:this.bgColor='$color2'\" onmouseout=\"javascript:this.bgColor='$color'\"><TD valign=\"top\"><table width=100%><tr bgcolor=#e9e9e9><td widht=50%>".$g."</td></tr></table>".$room_name."<br>+".$objective."<br>จำนวน ".$row_rsConfirm['person_num']." คน<br>".$name."&nbsp;&nbsp;".$surname." ".$d." ".$e."<br>$start_time น. ถึง $finish_time น.</TD></TR>");
				$conf++;
			}	//end while
			print("</TABLE></td>");		//สิ้นสุดคอลัมส์ในแต่ละวัน

						if ($day_of_week == 7) {
                                $day_of_week = 0;
                                print("\n</TR>");
                        }
                        $day_of_week += 1;
                }

                /**** Next Greyed month days */
                $day = 1;
                While (($day_of_week <= 7) && ($day_of_week != 1)) {
						##########	     วันในเดือนถัดไป     |-------------------------------------------
                        print("<TD align=center valign=top>$day</TD>");
                        $day_of_week += 1;
                        $day += 1;
                }
                print("\n</TR>\n</TABLE>\n</td></tr></table></CENTER>");
		}

}	//end if( !($index=='')
?>