|
|
|
มีคำถามเกี่ยวกับเช็คสถานะการจอง ช่วยเข้ามาดูให้หน่อยค่ะ |
|
|
|
|
|
|
|
นี่คือรูปเวลาแสดงการจอง
|
|
|
|
|
Date :
2012-09-08 15:01:28 |
By :
lakkhana |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[font=Verdana]
นี่คือฟังก์ชั่นต่างๆๆ[/font]
/* function เช็ตเวลาราสัปดาห์ */
function checkdateall($timein,$timeout,$fdate,$ldate,$name_room)
{
$date1 = date("Y-m-d",strtotime($fdate));
$date2 = date("Y-m-d",strtotime($ldate));
while($date2 >= $date1)
{
if($date2 >= $date1)
{
$datein = $timein;
$in = date("H:i:s",strtotime($datein));
$dateout = $timeout;
$out = date("H:i:s",strtotime($dateout));
con_db();
$sqlCheck = "SELECT * FROM reserve";
$result = mysql_query($sqlCheck);
while($row = mysql_fetch_assoc($result))
{
if($row["name_room"] == $name_room)
{
/* return false; */
if($row["date_reserve"] == $date1)
{
if($in <= $row["timein"] && $out >= $row["timeout"] )
{
return false;
}
if(($row["timein"] <= $in && $row["timeout"] >= $in) || ($row["timein"] <= $out && $row["timeout"] >= $out))
{
return false;
}
}
}
}
}
$date1 = date("Y-m-d",strtotime($date1)+(7*24*3600));
}
return true;
}
/* function เช็ตเวลารายวัน */
function checkdateall2($timein,$timeout,$fdate,$name_room)
{
$date1 = date("Y-m-d",strtotime($fdate));
$datein = $timein;
$in = date("H:i:s",strtotime($datein));
$dateout = $timeout;
$out = date("H:i:s",strtotime($dateout));
con_db();
$sqlCheck = "SELECT * FROM reserve";
$result = mysql_query($sqlCheck);
while($row = mysql_fetch_assoc($result))
{
if($row["name_room"] == $name_room)
{
if($row["date_reserve"] == $date1)
{
if($in <= $row["timein"] && $out >= $row["timeout"] )
{
return false;
}
if(($row["timein"] <= $in && $row["timeout"] >= $in) || ($row["timein"] <= $out && $row["timeout"] >= $out))
{
return false;
}
}
}
}
return true;
}
function showDate_time($room,$day1,$day2)
{
$dateF = date("Y-m-d",strtotime($day1));
$dateL = date("Y-m-d",strtotime($day2));
?>
<center><table border="0" style="font-size:16px;border-collapse: collapse; margin-top:20px;"><tr><td>
<?
echo 'Room : '.$room.' Between '.DateThai($dateF).' To '.DateThai($dateL).'</br>';
?>
</td></tr></table></center>
<style type="text/css"></style>
<table border="1" style="font-size:12px;border-collapse: collapse; margin-top:20px;" width="100%" >
<th align="center"><span class="style2">Date/Time
</td>
</span>
<th align="center"><span class="style2">08:00-09:00
</td>
</span>
<th align="center"><span class="style2">09:00-10:00
</td>
</span>
<th align="center"><span class="style2">10:00-11:00
</td>
</span>
<th align="center"><span class="style2">11:00-12:00
</td>
</span>
<th align="center"><span class="style2">12:00-13:00
</td>
</span>
<th align="center"><span class="style2">13:00-14:00
</td>
</span>
<th align="center"><span class="style2">14:00-15:00
</td>
</span>
<th align="center"><span class="style2">15:00-16:00
</td>
</span>
<th align="center"><span class="style2">16:00-17:00
</td>
</span>
<th align="center"><span class="style2">17:00-18:00
</td>
</span>
<th align="center"><span class="style2">18:00-19:00
</td>
</span>
<th align="center"><span class="style2">19:00-20:00
</td>
</span>
<?
$timeMain = array("08:00-08:30","08:30-09:00","09:00-09:30","09:30-10:00","10:00-10:30","10:30-11:00","11:00-11:30","11:30-12:00","12:00-12:30","12:30-13:00","13:00-13:30","13:30-14:00","14:00-14:30","14:30-15:00","15:00-15:30","15:30-16:00","16:00-16:30","16:30-17:00","17:00-17:30","17:30-18:00","18:00-18:30","18:30-19:00","19:00-19:30","19:30-20:00");
while($dateF<=$dateL)
{
?>
<tr>
<td align="center"><?=$dateF?></td>
<?
$i =0;
while ($i<23)
{
?>
<td align="center">
<table border="0" style="border-collapse: collapse;width:27px;height:27px;">
<tr>
<td>
<?
$chktime = chktime($timeMain[$i],$dateF,$dateL,$room);
if($chktime == '')
{ $desc = "available";
$chktime = '<img src="images/null.png" class="box" title="'.$desc.'"/>';
}
echo $chktime;
?>
</td>
<? $i++;?>
<td>
<?
$chktime = chktime($timeMain[$i],$dateF,$dateL,$room);
if($chktime == '')
{ $desc = "available";
$chktime = '<img src="images/null.png" class="box" title="'.$desc.'"/>';
}
echo $chktime;
?>
</td>
<? $i++;?>
</tr>
</table>
</td>
<?
}
?>
</tr>
<?
$dateF = date("Y-m-d",strtotime($dateF."+ 1 day"));
}
?>
</table>
<?
}
function chktime($timeChk,$dateF,$dateL,$name_room)
{
con_db();
$sql = "SELECT * FROM reserve WHERE name_room = '".$name_room."' AND status_reserve = 1 limit 10";
$result = mysql_query($sql)or die(mysql_error());
list($Ctimein,$Ctimeout) = explode("-", $timeChk);
$Ctimein = date("H:i:s",strtotime($Ctimein));
$Ctimeout = date("H:i:s",strtotime($Ctimeout));
while($row = mysql_fetch_array($result))
{
$in = $row['timein'];
$out = $row['timeout'];
$desc = $row['desc_reserve'];
$user = $row['username'];
$date = $row['date_reserve'];
if ($dateF == $date)
{
if(($Ctimein <= $in && $in < $Ctimeout) && $dateF == $date )
{
$img = '<img src="images/red.png" class="box" title="Detail : '.$desc.' User : '.$user.'"/>';
return $img;
}
elseif(($Ctimein < $out && $out <= $Ctimeout) && $dateF == $date)
{
$img = '<img src="images/red.png" class="box" title="Detail : '.$desc.' User : '.$user.'"/>';
return $img;
}
elseif(($Ctimein >= $in && $Ctimeout <= $out) && $dateF == $date)
{
$img = '<img src="images/red.png" class="box" title="Detail : '.$desc.' User : '.$user.'"/>';
return $img;
}
}
}
}
|
|
|
|
|
Date :
2012-09-08 15:05:08 |
By :
lakkhana |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|