MINI SHELL

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/meetingroom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/pathumthani_eoffice/application/meetingroom/reserve_summary_bk20100503c.php
<?
//include("chk_permission.php");
session_start();
include("../../config/config.inc.php");
include("../../common/function.php");
include("var.inc.php");

//insert timeQuery
include("../../common/common_system.inc.php"); 
$ApplicationName="metting"; 
$time_start = getmicrotime();  
//insert timeQuery


$appsession = $_SESSION[session_apppermit][3];

if (!$_POST) {
	if (!$date_start){ $date_start=convert2th(convert_mysql2carendar(date("Y-m-1"))); } 
	if (!$date_end){ $date_end=convert2th(convert_mysql2carendar(date("Y-m-d"))); }
}

//echo $appid;
//echo "<pre>";
//print_r($_SESSION);

################ HARD FIX
#$_SESSION[session_staffid] = 49 ;
$user=$_SESSION[session_staffid];
################
if ($jump != ""){$jump=$jump;}else{$jump=date("d") ."/". date("m") ."/". date("Y") ;  $jump = $jump; } 


/*  
function jump_daythai($cal_format){
	$smonth = array("","ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
	$arr_day = explode("/",$cal_format) ;  
	$mm = (int)$arr_day[1] ; 
	$thyy =  (int)$arr_day[2] + 543 ; 
	$daythai = (int)$arr_day[0] ."  ".  $smonth[$mm]  ."  ".  $thyy   ;
	return $daythai ; 
} ################# function jump_daythai($cal_format){
*/
function DateDiff($strDate1,$strDate2){ //yyyy-mm-dd              
    return (strtotime($strDate2) - strtotime($strDate1))/  ( 60 * 60 * 24 );  // 1 day = 60*60*24     
} 
function cutlast2digit($strx){
	$len1 = strlen($strx)-3 ; 
	$newval = substr($strx,0,$len1 ) ; 
	return $newval ; 
}################# function cutlast2digit($cal_format){

function toStaffName($staffid) {
	$sqlx = "SELECT staffname FROM epm_staff WHERE staffid='$staffid'";
	$qx = mysql_query($sqlx) or die(mysql_error());
	$rx = mysql_fetch_assoc($qx);
	if (!$rx[staffname]) { $rx[staffname]="ไม่ระบุ"; }
	return $rx[staffname];
}

function getRoomName($rid) {
	$sqlx = "SELECT rname FROM meeting_room WHERE rid='$rid'";
	$qx = mysql_query($sqlx) or die(mysql_error());
	$rx = mysql_fetch_assoc($qx);
	if (!$rx[rname]) { $rx[rname]="ไม่ระบุ"; }
	return $rx[rname];
}

function getRentPrice($rid) {
$time_def = 0;
$time_def_check= 0;
	//$sqlx = "SELECT rrent,rper FROM meeting_room WHERE rid='$rid'";		
$sqlx="SELECT refid,roomid,rid,rrent,rper,admin_confirm,
concat( (meeting_reserve.time_end - meeting_reserve.time_start )/10000) as time_def,
meeting_reserve.time_start,
meeting_reserve.time_end
FROM meeting_reserve Left outer Join meeting_room ON meeting_room.rid = meeting_reserve.roomid	 WHERE refid='$rid'";			

	$qx = mysql_query($sqlx) or die(mysql_error());
	$rx = mysql_fetch_assoc($qx);

	$time_def = ( intval($rx[time_def]) != $rx[time_def] ) ? intval($rx[time_def]) + 0.5 : intval($rx[time_def]);
	intval($rx[time_def]) ."!=". $rx[time_def]."<br>";

	$costtemp = $rx[rrent] * $time_def;
	return $costtemp	;
}



//=============================================================
// Constant Variable
//=============================================================
$arr_status = array(0=>"ทั้งหมด", 1=> "ชำระแล้ว", 2=> "ค้างชำระ" );
?>
<html>
<head><title>ระบบจองห้องประชุม</title>
<meta http-equiv="content-type" content="text/html; charset=windows-874">
<link href="../../common/style.css" rel="stylesheet" type="text/css">
<link href="../../common/tab_style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../../common/popcalendar.js"></script>
<script language="javascript" src="../../common/xmlhttp.js"></script>
<script type="text/javascript" src="../../common/tabber.js"></script>
<script language="javascript" src="../../common/NumberFormat154.js"></script>
<script>
	function genXHR(){
		var xmlHttp=null;
				try{
					// Firefox, Opera 8.0+, Safari
					xmlHttp=new XMLHttpRequest();
				}catch (e){
					// Internet Explorer
					try{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}catch (e){
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
				}
		return xmlHttp;
	}

	function displayCommand(obj,id,aa){
		j=genXHR();
		j.onreadystatechange=function() { 
			if (j.readyState==4 || j.readyState=="complete"){ 
				obj.parentNode.innerHTML=j.responseText;
			}
		}
		var nf = new NumberFormat(aa);
		nf.setPlaces(0);
		nf.setSeparators(true);
		var num = nf.toFormatted();

		j.open("GET","ajax.php?ts="+new Date().getTime()+"&qu=show&id="+id+"&aa="+num, true);
		j.send(null);
	}
	
	function updateCost(obj,id,aa,remain){
	  	j=genXHR();
		repaid=document.getElementById("abc").value;
		if(remain==repaid){
			obj.parentNode.parentNode.childNodes[7].innerHTML="<img src=\"\../../images/check.png\" />";
		}
		j.onreadystatechange=function() { 
			if (j.readyState==4 || j.readyState=="complete"){ 
								window.location=window.location;
			}
		}
		
		j.open("GET","ajax.php?ts="+new Date().getTime()+"&qu=update&id="+id+"&aa="+aa+"&repaid="+repaid, true);
		j.send(null);
	}
//==================================================
//  Open pop up windows
// @date 2009/06/07
// @param URL  a url that open
// @param N a name
// @param W a window width
// @param H a windows height
// @param S state of scrollbars of popup window
//==================================================
function popUpWindow(URL, N, W, H, S) 
{ 
	H = (H > screen.height -100)? screen.height-100 : H;
	var winleft    =    (screen.width - W) / 2;
	var winup    =    (screen.height - H) / 2;
	winProp        =    'width='+W+',height='+H+',left='+winleft+',top=' +winup+',scrollbars='+S+',resizable' + ',status=yes'
	Win            =    window.open(URL, N, winProp)
	if (parseInt(navigator.appVersion)  >= 4) 
	{ 
		Win.window.focus(); 
	}
}
</script>
</head>
<body topmargin="0" bgcolor="#EEEEEE">

<? 			 	
	$title_label = "ระบบจองห้องประชุม";
	include "header.php";
	include "menu_bar.php";
?>
<?
		$filter = "";
		if($_GET)
		{
			$operation = "";
			if($_GET[selStatus] != 0)
			{
				if($_GET[selStatus] == 1)
				{
					$operation = " = '31' ";
				}else if($_GET[selStatus] == 2)
				{
					$operation = " != '31' ";
				}
				$filter = " AND meeting_reserve.admin_confirm  $operation ";
			}
		}
		$xdate_start = convert_2mysql($date_start);
		$xdate_end = convert_2mysql($date_end);
		if ($rid) { 
			$sql1 = "SELECT meeting_reserve.*, org_staffgroup.groupname as groupname  
			FROM meeting_reserve INNER JOIN  epm_staff  ON meeting_reserve.staff_regis = epm_staff.staffid  
			INNER JOIN org_groupmember ON epm_staff.staffid = org_groupmember.staffid  
			INNER JOIN org_staffgroup ON org_staffgroup.gid = org_groupmember.gid 
			 WHERE roomid='$rid' AND daterent BETWEEN '$xdate_start' AND '$xdate_end' $filter";
			$sql2 = "SELECT SUM(meeting_reserve.cost_request) AS trent FROM meeting_reserve WHERE meeting_reserve.roomid='$rid' AND meeting_reserve.daterent BETWEEN '$xdate_start' AND '$xdate_end' GROUP BY meeting_reserve.roomid"; 
			$sql3  = "SELECT daterent,COUNT(daterent) as num FROM meeting_reserve WHERE roomid='$rid' AND daterent BETWEEN '$xdate_start' AND '$xdate_end' GROUP BY daterent";
		} else { 
			$sql1 = "SELECT meeting_reserve.*, org_staffgroup.groupname as groupname  
			FROM meeting_reserve INNER JOIN  epm_staff  ON meeting_reserve.staff_regis = epm_staff.staffid  
			INNER JOIN org_groupmember ON epm_staff.staffid = org_groupmember.staffid  
			INNER JOIN org_staffgroup ON org_staffgroup.gid = org_groupmember.gid 
			WHERE daterent BETWEEN '$xdate_start' AND '$xdate_end' $filter"; 
			$sql2 = "SELECT SUM(meeting_reserve.cost_paid) AS trent FROM meeting_reserve WHERE meeting_reserve.daterent BETWEEN '$xdate_start' AND '$xdate_end' GROUP BY meeting_reserve.roomid"; 
			$sql3 = "SELECT daterent,COUNT(daterent) as num,sum(cost_request) as cost_request ,sum(cost_paid) as cost_paid  FROM meeting_reserve WHERE daterent BETWEEN '$xdate_start' AND '$xdate_end' GROUP BY daterent"; 
		}
	//	echo $sql1;
		$qx1 = mysql_query($sql1) or die(mysql_error());
		$nrowx1 = mysql_num_rows($qx1);
		$qx2 = mysql_query($sql2) or die(mysql_error());
		if($rid) {
			$rsx2 = mysql_fetch_assoc($qx2);
			$sumx=$rsx2[trent];
		} else {
			while($rsx2 = mysql_fetch_assoc($qx2)) {
				$sumx=(int)$sumx+(int)$rsx2[trent];
			}
		}
	?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" valign="top"><form name="form1" method="post" action="">
				  <br>
				  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
                      <tr>
                        <td width="50%" align="center"><table width="350" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
                          <tr>
                            <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                                <tr>
                                  <th align="right" bgcolor="#EEEEEE"><strong>สรุปการใช้งานห้องประชุม</strong></th>
                                  <td bgcolor="#EEEEEE"><strong>
                                    <select name="rid" id="rid" style="width:100px;">
                                      <option value="0" <? if($rid==0){?>selected="selected"<? } ?>>ทั้งหมด</option>
                                      <? $sqlx = "SELECT rid,rname FROM meeting_room ORDER BY rid ASC";
									$qx = mysql_query($sqlx) or die(mysql_error());
									while($rx = mysql_fetch_assoc($qx)) { ?>
                                      <option value="<?=$rx[rid];?>" <? if($rid==$rx[rid]){?>selected="selected"<? } ?>>
                                        <?=$rx[rname];?>
                                      </option>
                                      <? } ?>
                                    </select>
                                  </strong></td>
                                </tr>
                                <tr>
                                  <th align="right" bgcolor="#EEEEEE"><strong>ระหว่างวันที่</strong></th>
                                  <td bgcolor="#EEEEEE"><strong>
                                    <input name="date_start" type="text" value="<?=$date_start;?>" size="15" readonly>
                                    <input name="button2" type="button" class="index2" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_start, 'd/m/yyyy')" value='เลือกวัน'>
                                  </strong></td>
                                </tr>
                                <tr>
                                  <th align="right" bgcolor="#EEEEEE"><strong>ถึงวันที่</strong></th>
                                  <td bgcolor="#EEEEEE"><strong>
                                    <input name="date_end" type="text" value="<? if (!$date_end){echo convert2th(convert_mysql2carendar(date("Y-m-d")));}else{echo $date_end;} ?>" size="15" readonly>
                                    <input name="button" type="button" class="index2" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_end, 'd/m/yyyy')" value='เลือกวัน'>
                                  </strong></td>
                                </tr>
								<tr>
                                  <th align="right" bgcolor="#EEEEEE">&nbsp;</th>
                                  <td bgcolor="#EEEEEE"><input type="radio" name="type_search"  value="0"  <?=($_POST[type_search] == 0)? "checked" : "" ?>>แสดงภาพรวมรายวัน</td>
                                </tr>
								<tr>
                                  <th align="right" bgcolor="#EEEEEE">&nbsp;</th>
                                  <td bgcolor="#EEEEEE"><input type="radio" name="type_search"  value="1" <?=(!$_POST || $_POST[type_search] == 1)? "checked" : "" ?>>แสดงรายรายการ</td>
                                </tr>
                                <tr>
                                  <th colspan="2" align="center" bgcolor="#EEEEEE"> <input name="Submit" type="submit" class="epm_button" value="     เรียกดู     ">
                                  </th>
                                </tr>
                            </table></td>
                          </tr>
                        </table></td>
                        <td width="50%" align="center"><table width="300" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
                          <tr>
                            <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                                <tr>
                                  <td width="50%" align="right" bgcolor="#466A8E" class="txtwhite"><strong>สรุปการใช้งานห้องประชุม</strong></td>
                                  <td width="50%" align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <? 	if($rid!=0)
											{
												echo " ".getRoomName($rid);
											}else
											{ 
												if($_GET)
												{
													$str_temp = ($_GET[selStatus] == 1 || $_GET[selStatus]==2)? "ห้องที่" : "";
													echo $str_temp.$arr_status[$_GET[selStatus]];
												}else
												{
													echo $arr_status[0];
												}
											}
									?>
                                  </strong></td>
                                </tr>
                                <tr>
                                  <td width="50%" align="right" bgcolor="#466A8E" class="txtwhite"><strong>ระหว่างวันที่</strong></td>
                                  <td width="50%" align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <? if (!$date_start){echo daythai2(date("Y-m-d"));}else{echo daythai2(convert_2mysql($date_start));} ?>
                                  </strong></td>
                                </tr>
                                <tr>
                                  <td width="50%" align="right" bgcolor="#466A8E" class="txtwhite">ถึงวันที่</td>
                                  <td width="50%" align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <? if (!$date_end){echo daythai2(date("Y-m-d"));}else{echo daythai2(convert_2mysql($date_end));} ?>
                                  </strong></td>
                                </tr>
                                <tr>
                                  <td align="right" bgcolor="#466A8E" class="txtwhite">มีการใช้งาน</td>
                                  <td align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <?=$nrowx1;?>
                                  ครั้ง</strong></td>
                                </tr>
                                <tr>
                                  <td align="right" bgcolor="#466A8E" class="txtwhite">ชำระแล้ว</td>
                                  <td align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <?
																			
									echo	set_currency($sumx);
									?>
                                    บาท</strong></td>
                                </tr>
                                <tr>
                                	<td align="right" bgcolor="#466A8E" class="txtwhite">จำนวนค้างชำระ</td>
                                  <td align="left" bgcolor="#466A8E" class="txtwhite"><strong>
                                    <?php
									        $temp=0;//หาเงินค้างชำระ
											$qx12= mysql_query($sql1) or die(mysql_error());
											while($rx15 = mysql_fetch_assoc($qx12)){
												$diff=$rx15[cost_request]-$rx15[cost_paid];
												//echo "$rx15[cost_request]     $rx15[cost_paid]  <br>";
												$temp+=($diff>0)?$diff:0;
											}
											echo set_currency($temp);
									?>
                                    บาท</strong></td>
                                </tr>
                            </table></td>
                          </tr>
                        </table></td>
                      </tr>
        </table>
				    <br>
				  </form>
<?
//=================================================
// แสดงรายรายการ
//=================================================
	if(!$_POST || $_POST[type_search] == 1)
	{
?>
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
          <tr  >
            <td height="10" colspan="10" align="right" ><table width="400" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="../../images/check.png" width="20" height="20"></td>
    <td>หน่วยงานผู้ใช้ห้องประชุมชำระแล้ว&nbsp;&nbsp;</td>
    <td><img src="../../images/close.png" width="20" height="20"></td>
    <td>หน่วยงานผู้ใช้ห้องประชุมยังไม่ชำระ&nbsp;&nbsp;</td>
  </tr>
</table>
</td>
          </tr>
          <tr  align="center" bgcolor="#466A8E"  class="headerTB_white" >
            <td height="10" colspan="10" align="right" >
              <form id="formFilter" name="formFilter" method="get" action="">
                สถานะการชำระ
                <select id="selStatus" name="selStatus">
                  <?
					foreach($arr_status as $key => $value)
					{
						$str_chk = ($key == $_GET[selStatus])? "selected":"";
						echo "<option value='$key' $str_chk>$value</option>";
					}
				?>
                  </select>
                <input type="submit" value="แสดง">
              </form> </td>
          </tr>
          <tr  align="center" bgcolor="#466A8E"  class="headerTB_white" >
            <td width="4%" height="20" >ลำดับ</td>
            <td width="8%" height="20">วัน/เดือน/ปี</td>
            <td width="5%">เวลา</td>
            <td width="8%">ห้องประชุม</td>
            <td width="20%">หัวข้อการประชุม</td>
            <td width="14%">หน่วยงานที่ใช้บริการ</td>
            <td width="12%">ผู้เข้าประชุม(คน)</td>
            <td width="8%">อัตราค่าเช่า</td>
            <td width="11%" >เลขที่ใบเสร็จ</td>
            <td width="11%" >สถานะการชำระ  </td>
        </tr>
          <?
			while($rx = mysql_fetch_assoc($qx1)) {
			if ($bgcolor1 == "DDDDDD"){  $bgcolor1 = "EFEFEF"  ; } else {$bgcolor1 = "DDDDDD" ;}
			$i++;
			$time1=explode(":",$rx[time_start]);
			$time2=explode(":",$rx[time_end]);
			list($aa,$bb)=explode(" ",getRentPrice($rx[refid]));
			
			//if(($rx[cost_request]-$rx[cost_paid]) > 0 ){
			if($rx[admin_confirm] != 31){
				$img_status="close.png";				
				$date1=$rx[daterent];
				$datenow=date('Y-m-d');
//				if(DateDiff($date1,$datenow)<0){
//				 $img_status="";
//					//$command_but="<input type=\"button\" value=\"ชำระเงิน\" onclick=\"displayCommand(this,'".$rx[refid]."',".$aa.")\" />";		
//			
//					}
//				else{
//								$img_status="close.png";
//				//$command_but="<input type=\"button\" value=\"ชำระเงิน\" onclick=\"displayCommand(this,'".$rx[refid]."',".$aa.")\" />";	
//				$altstr="ยังไม่ได้ชำระเงิน";
//					}

				
			}elseif($rx[admin_confirm] == 31){
				$img_status="check.png";
						$altstr="ชำระแล้ว";
				$command_but="<span style=\"width:60px;height:20px;background-color:#D6D6D6;color:#EEEEEE;border:#C8C1C6 solid 1px;text-align:center;\">ชำระแล้ว</span>";
			}else{
				
			}
		?>
          <tr  bgcolor="#<?=$bgcolor1?>">
            <td align="center" valign="top"><?= $i;?></td>
            <td align="center" valign="top"><?=daythai2($rx[daterent]);?></td>
            <td align="center" valign="top"><?=(int)$time1[0];?>.<?=$time1[1];?> - <?=(int)$time2[0];?>.<?=$time2[1];?></td>
            <td align="center" valign="top"><?=getRoomName($rx[roomid]);?></td>
            <td align="left" valign="top"><? if (!$rx[meeting_topic]) { echo"ไม่ระบุ"; }else{echo $rx[meeting_topic];}?></td>
            <td align="left" valign="top"><?= $rx[groupname]?></td>
            <td align="right" valign="top"><?=$rx[meeting_person]?></td>
            <td align="right" valign="top"><?
			if($rx[daterent] >= "2010-05-01"){
				list($aa,$bb)=explode(" ", getRentPrice($rx[refid]));
				echo set_currency($aa). $bb ;
				
				//if($session_apppermit[$m_id ][10] == "on"){ echo $command_but;} 
			}
			?>&nbsp;</td>
            <td align="center" valign="top"><?=$rx[billCost]?></td>
            <td align="center" valign="top">
            <?
            if($img_status!=""){
				?>
				  <img src="../../images/<?php echo $img_status; ?>" alt="<?=$altstr?>" />
				<?
				}
			?>
          
            </td>
          </tr>
          <? } ?>
    </table>
	  <br>
<?
//============================================== 
// จบการแสดงรายรายการ
//============================================== 
} else if($_POST[type_search] == 0)
{
?>
<table width="95%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">

  <tr  align="center" bgcolor="#466A8E"  class="headerTB_white" >
    <td width="5%" height="20" >ลำดับ</td>
    <td width="20%" height="20">วัน/เดือน/ปี</td>
    <td width="25%">จำนวนการใช้ห้องประชุมทั้งสิ้น(รายการ)</td>
    <td width="25%">ค่าเช่าห้องประชุม(บาท)</td>
    <td width="25%">จำนวนวงเงินค้างชำระ(บาท)</td>
    </tr>
<?               
	$qr = mysql_query($sql3) or die(mysql_error());
	$i = 1;
	while($rss = mysql_fetch_assoc($qr))
	{     
		if($rss[num] > 0)
		{
				if ($bgcolor1 == "DDDDDD"){  $bgcolor1 = "EFEFEF"  ; } else {$bgcolor1 = "DDDDDD" ;}
			$date = explode("-",$rss[daterent]) ;
			$iday = $date[2];
			$month = $date[1];
			$year = $date[0];
					
			$show = $rss[num] ;
			$h_win_pop = $rss[num]*135;                    
			?>
			  <tr  bgcolor="#<?=$bgcolor1?>">
			<td align="center" valign="top"><?=$i?></td>
			<td align="center" valign="top"><?=daythai2($rss[daterent])?></td>
			<td align="center" valign="top">
			<?print "$str<a href='#' onClick=\"popUpWindow('pop_detail.php?day=$iday&month=$month&year=$year', 'SH1', 450,$h_win_pop, 'yes') \"><strong>$show</strong></a><br>\n";?>
			</td>
            <td align="center" valign="top">&nbsp;<?=$rss[cost_request]?></td>
            <td align="center" valign="top">&nbsp;<?=$rss[cost_request]-$rss[cost_paid]?></td>
			</tr>
			<?
			$i++;
		}   
	}
?>
</table>
<table align="center" width="400px" border="0">
</table>
<?
}
?></td>
  </tr>
</table>
</body>
</html>
<?
//insert timeQuery
 $time_end = getmicrotime();
  writetime2db($timestart,$timeend);
//insert timeQuery
?>

Anon7 - 2021