<?php


require('../config/config.php');

$month = intval($_GET['q']);
if($month == ''  || !isset($_GET['q']))
{
$month = date("M");
}
$hotel_id = ($_GET['hids']);
//echo $hotel_id;
//echo $hotel_id ;
$year = date("y");

		$hotelObClnder = new Calendar;
		$Emnth = $hotelObClnder->mnth_trsform($month);
		$hotelObClnder->current_Date($month,$year);
		//echo "<br>";
		$hotelObClnder->setcrntmnth($month);
		$crntvmnth = $hotelObClnder->getcrntmnth();
		//echo "<br>Crnt_Mnth".$crntvmnth;
		$hotelObClnder->setcrntyear($year);
		$crntyear = $hotelObClnder->getcrntyear();
		//echo "<br>Crnt_Year<br>".$crntyear;
		$hotelObClnder->setprevmnth($month-1);
		$prevmnth = $hotelObClnder->getpreviousmnth();
		//echo "P_MNTH_CHART".$prevmnth ;
		$hotelObClnder->setnxtmnth($month+1);
		$hotelObClnder->setprevyear($year);
		$prevyear = $hotelObClnder->getprevyear();

		$nextmnth = $hotelObClnder->getnxtmnths();
		$hotelObClnder->setnxtyear($year);
		$nextyear = $hotelObClnder->getnxtyear();
		//echo "<br> Next Year <br>".$nextyear;
		if($prevmnth == 0) 
		{
		$prevmnth = 12 ;	//$previousmnth = 12 ;
		$hotelObClnder->setcrntmnth($prevmnth);
		$prevyear = $crntyear-1;
		$hotelObClnder->setcrntyear($prevyear);
		//$hotelObClnder->setprevyear($crntyear-1 ); //$prev_year = $year-1;

		}
		if($nextmnth == 13 )
		{
		$nextmnth = 1 ;
		$hotelObClnder->setcrntmnth($nextmnth );
		$nextyear = $crntyear+1;
		$hotelObClnder->setcrntyear($nextyear);
		//$hotelObClnder->setnxtmnth(1); //$nxtmnth = 1 ;
		//$hotelObClnder->setnxtyear($crntyear+1); //$nxt_year = $year+1;

		}
		
		$crntvmnth = $hotelObClnder->getcrntmnth();
		//echo "Current Month".$crntvmnth;
		$month = $crntvmnth ;
		$tdays = $hotelObClnder->daysInMonth($month,$year);
		//echo $tdays;
		$hotelObR = new classRoom;
		$hotelObR->setHotelID($hotel_id);
		$hotelDataObRoom = $hotelObR->retrieveRoomsTypesByHotelID($hotel_id);
		$items = array();

?>
<body>


<br><small><div align="center">Current Month : <?php echo $Emnth." , " .$year; ?> </div></small></br>
<table class="table table-bordered table-striped table-booking-history">
<thead>	
		<tr>
		<th> </th>
		<?php
		$tdays = $hotelObClnder->daysInMonth($month,$year);

		for($r=1; $r<=$tdays; $r++)
		{  ?>


		<th><?php
		echo $r; ?>
		</th> 
		<?php }

		?>
		</tr> <?php  ?> 
</thead>

		<tbody>
	<?php 
		$hotelObR = new classRoom;
		$hotelObR->setHotelID($hotel_id);
		$hotelDataObRoom = $hotelObR->retrieveRoomsTypesByHotelID($hotel_id);
		$items = array();
		$room_type = array();
		$status = array();
		for($i=0;$i<count($hotelDataObRoom); $i++) /// Total Rows
		{  
	?>

		<tr>
		<td><b>
	<?php 
		$items[$i] = $hotelDataObRoom[$i]['hotel_room_id'] ;
		//echo $items[$i]; 
		$hotelDataObRoomType = $hotelObR->retrieveRoomsTypesByRoomId($items[$i]);
		$room_type[$i] = $hotelDataObRoomType[0]['hotel_room_type'];
		ECHO $room_type[$i];
	?>

		</b> </td> 
	<?php 
		$tdays = $hotelObClnder->daysInMonth($month,$year);
		$hotelObClnder->setnxtmnth($month+1);
		$hotelObClnder->setprevyear($year);
		$prevyear = $hotelObClnder->getprevyear();

		if ($month >1 && $month <= 10 ) {
		/* add in the day number */
		$event_day = $year.'-'.$month ;}
		else{
		$event_day = $year.'-'.$month;
		}
	?>
	<?php
		for($r=1; $r<=$tdays; $r++)
		{ 
		if($r >= 1 && $r < 10)
		{
		$r = "0".$r."";
		$event_day = $year.'-0'.$month.'-'.$r;
		}
		else
		{
		$event_day = $year.'-0'.$month.'-'.$r;
		}

		//echo strtotime($event_day);
		//$status[$r] = $hotelObClnder->getStatus(strtotime($event_day),$items[$i],$hotel_id);
		//echo $status[$r];
	 	
		//$image = $UpdateObj->getStatus(strtotime($date),$t,$HID); 	
	?>
	 	

		<td>
		<div id="result">
		<input type="image"  src="<?php echo $hotelObClnder->getStatus(strtotime($event_day),$items[$i],$hotel_id); ;?> " height="15px" width="15px" align="center"  onClick="return validateForm('<?php echo $event_day; ?>','<?php echo $items[$i] ; ?>','<?php echo $hotel_id ; ?>')"  value="here">
		<div id="txtHint"><b>
</div>
		</b></div>	
		</td>						
		<?php  // UpdateStatus(".base64_encode($event_day).",".base64_encode($items[$i]).",".base64_encode($hotel_id).")'
		}?><?php } ?>
		</tbody>
</table>

</body>

