<?php
session_start();
if( isset($_POST["dat"]) && isset( $_POST['hotelID'] )){
	 $hid=$_POST['hotelID'];
	$date=$_POST["dat"];
	//$dd = $_POST["days"];
	 
	
include("buda_connect.php");
//$da=1;
?><table border=1 id="b"><?php
/*while($da<=$dd){
	if($da<10){
	$date=$de."-0".$da;
	}
	else{
	$date=$de."-".$da;	
	}*/
	 ?>
	 <tr><td colspan=7>ROOM SERVICES SUMMARY FOR<?php echo $date;?></b> </td></tr>
	 
	 <tr id="tdprof"><td id=" "><font size=2  type="agency fb"> ROOM NO</font></td>
	
	<td id=" "><font size=2  type="agency fb"> ROOM NAME</font></td>
	
	<td id=" "><font size=2  type="agency fb"> ROOM COST</font></td>
	
	<td id=" "><font size=2  type="agency fb"> ROOM TYPE</font></td>
	
	<td id=" "><font size=2 type="agency fb"> CUSTOMER NAME</font></td>
	
	<td id=" "><font size=2  type="agency fb"> CASH AMOUNT</font></td>
	
	<td id=" "><font size=2  type="agency fb">PAYMENT STATUS</font></td>
	  
	</tr>
	 
	 <?php

$qH=mysql_query("select room_no,rname,rcost,rtype,rstatus from room where hotel_id='$hid'")or die("Error3: ".mysql_error());
$ht=mysql_num_rows($qH);
if($ht > 0){
 $av=0;
 
 
	 $rum = array();
while($av<$ht){
	 $OD=mysql_fetch_array($qH);
	 
	 array_push($rum,array('room_no'=>$OD[0],
	                         'rname'=>$OD[1],
							 'rcost'=>$OD[2],
							 'rtype'=>$OD[3],
							 'rstatus'=>$OD[4]
							 ));
				 




$queryH=mysql_query("select recept_no,hotel_id,room_id,cust_id,pay_type,arrived_on,check_in_time,arivedf,departure_on,departure_to,no_of_night,nofguest,occupation_type,cash_amount,Age,car_reg,p_status,clerksign from  recept where hotel_id='$hid' and room_id='$OD[0]' and departure_on like '%$date%'")or die("Error1: ".mysql_error());


$hotno=mysql_num_rows($queryH);
 
	
	 $gethoD = array();
	
	 
	 
	 $OuthD=mysql_fetch_array($queryH);
	 
	 array_push($gethoD,array('recept_no'=>$OuthD[0],
	                         'hotel_id'=>$OuthD[1],
							  'room_id'=>$OuthD[2],
							 'cust_id'=>$OuthD[3],
							 'pay_type'=>$OuthD[4],
							 'arrived_on'=>$OuthD[5],
							 'check_in_time'=>$OuthD[6],
							 'arivedf'=>$OuthD[7],
							 'departure_on'=>$OuthD[8],
							 'departure_to'=>$OuthD[9],
							 'no_of_night'=>$OuthD[10],
							 'nofguest'=>$OuthD[11],
							 'occupation_type'=>$OuthD[12],
							 'cash_amount'=>$OuthD[13],
							 'Age'=>$OuthD[14],
							 'car_reg'=>$OuthD[15],
							 'p_status'=>$OuthD[16],
							 'clerksign'=>$OuthD[17]
 							  
							  
	             
				 ));
 			 
							 
$cust=mysql_query("select fname,mname,lname,address,email,nationality,post_code,profession from  customer where cust_id='$OuthD[3]' ")or die("Error3: ".mysql_error());

	$cu=mysql_num_rows($cust);

 
	 $rn = array();
	 
	 $ct=mysql_fetch_array($cust);                             
	 
	 array_push($rn,array('fname'=>$ct[0],
	                      'mname'=>$ct[1],
						  'lname'=>$ct[2],
						  'address'=>$ct[3],
						  'email'=>$ct[4],
						  'nationality'=>$ct[5],
						  'post_code'=>$ct[6],
						  'profession'=>$ct[7]
	                        
							 ));
							 
							 
							 
							 
							 
							 
							 
							 
							 
						?>
	<tr id="tdprof"><td id=" "><font size=2 type="agency fb"><?php echo $OD[0]; ?></font></td>
	
	<td id=" "><font size=2   type="agency fb"><?php echo $OD[1]; ?></font></td>
	
	<td id=" "><font size=2   type="agency fb"><?php echo $OD[2]; ?></font></td>
	
	<td id=" "><font size=2   type="agency fb"><?php echo $OD[3]; ?></font></td>
	  
	<td id=" "><font size=2  type="agency fb"><?php echo $ct[0]." ".$ct[1]." ".$ct[2]; ?></font></td>
	
	<td id=" "><font size=2 type="agency fb"><?php echo $OuthD[13]; ?></font></td>
	
	<td id=" "><font size=2  type="agency fb"><?php echo $OuthD[16]; ?></font></td>
	  
	</tr>
	
	 
<?php			 
 
 $total=$total+$OuthD[13];
  $total_expected=$total_expected+$OD[2];
 
 $av++;
}

}
else{
	echo "No room available!..".$hid." ".$dat." ".$days;
}
//$da++;
//}
?><tr id="tdprof"><td id=" ">
	<td id=" " colspan=8>Total amount money enhenced:<font size=2  type="agency fb"><?php echo $total; ?></font><p/>
	
	Total amount of  money expected:<font size=2  type="agency fb"><?php echo $total_expected; ?></font>
	
	</td>
	  
	</tr> </table><?php
}

							 
		?>